assert_all_are_ip_addresses

0th

Percentile

Does the character vector contain IP addresses?

Checks that the input contains IP addresses. (It does not check that the address exists, merely that the string is in a suitable format.)

Usage
assert_all_are_ip_addresses(x, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_are_ip_addresses(x, na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

is_ip_address(x)

Arguments
x

Input to check.

na_ignore

A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

Value

A logical vector that is TRUE when the input contains valid IP addresses.

Note

Valid IP addresses are considered to be four integers in the range 0 to 255, separated by dots, or the string "localhost".

Aliases
  • assert_all_are_ip_addresses
  • assert_any_are_ip_addresses
  • is_ip_address
Examples
# NOT RUN {
x <- c(
  localhost     = "localhost", 
  valid_address = "255.0.255.0", 
  out_of_range  = "1.2.3.256",
  five_blocks   = "1.2.3.4.5",
  non_numeric   = "1.2.3.Z",
  missing_block = "1.2.3.NA",
  missing       = NA
)
is_ip_address(x)
assert_any_are_ip_addresses(x)
#These examples should fail.
assertive.base::dont_stop(assert_all_are_ip_addresses(x))
# }
Documentation reproduced from package assertive.data, version 0.0-3, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.