assert_all_are_ip_addresses {assertive.data}R Documentation

Does the character vector contain IP addresses?

Description

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".

Examples

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))

[Package assertive.data version 0.0-3 Index]