pfSense-pkg-RESTAPI

IPAddressValidator extends Validator
in package

Defines a Validator that checks if a given value is a valid IPv4 or IPv6 address.

Table of Contents

Properties

$allow_alias  : bool
$allow_fqdn  : bool
$allow_ipv4  : bool
$allow_ipv6  : bool
$allow_ipv6_link_local  : bool
$allow_keywords  : array<string|int, mixed>
$allow_port  : bool
$field_context  : Field|null
$model_context  : Model|null

Methods

__construct()  : mixed
get_class_fqn()  : string
Obtains the fully qualified name of the called class.
get_class_shortname()  : string
Obtains the shortname of the called class.
get_classes_in_namespace()  : array<string|int, mixed>
Obtains all classes associated with this class's current namespace.
log_error()  : void
Logs an error to the syslog.
validate()  : void
Checks if a given value is a valid IP address.
set_label()  : mixed
Sets a label on the assigned $field_context if present.
validate_port_suffix()  : string
Checks if a given value is a valid socket address (ADDR:PORT) and validates that the port number is valid.

Properties

$field_context

public Field|null $field_context = null

The parent Model Field object that called this Validator.

$model_context

public Model|null $model_context = null

The parent Model object that called this Validator.

Methods

__construct()

public __construct([bool $allow_ipv4 = true ][, bool $allow_ipv6 = true ][, bool $allow_ipv6_link_local = true ][, bool $allow_alias = false ][, bool $allow_fqdn = false ][, bool $allow_port = false ][, array<string|int, mixed> $allow_keywords = [] ]) : mixed
Parameters
$allow_ipv4 : bool = true

Allow value to be an IPv4 address.

$allow_ipv6 : bool = true

Allow value to be an IPv6 address.

$allow_ipv6_link_local : bool = true

Allow value to be an IPv6 link local address. Only applies if $allow_ipv6 is true.

$allow_alias : bool = false
$allow_fqdn : bool = false

Allow value to be an FQDN.

$allow_port : bool = false

Allow value to end with a port number (e.g. :80).

$allow_keywords : array<string|int, mixed> = []

An array of non IP/FQDN values to allow.

get_class_fqn()

Obtains the fully qualified name of the called class.

public get_class_fqn() : string
Return values
string

The FQN for this object's class.

get_class_shortname()

Obtains the shortname of the called class.

public get_class_shortname() : string
Return values
string

The shortname for this object's class.

get_classes_in_namespace()

Obtains all classes associated with this class's current namespace.

public get_classes_in_namespace([bool $shortnames = false ]) : array<string|int, mixed>
Parameters
$shortnames : bool = false
Return values
array<string|int, mixed>

An array of classes currently in this object's namespace

log_error()

Logs an error to the syslog.

public static log_error(string $message) : void
Parameters
$message : string

The error message to write to the syslog

validate()

Checks if a given value is a valid IP address.

public validate(mixed $value[, string $field_name = '' ]) : void
Parameters
$value : mixed

The value to validate.

$field_name : string = ''

The field name of the value being validated. This is used for error messages.

Tags
throws
ValidationError

When the value is not a valid IPv4 address.

set_label()

Sets a label on the assigned $field_context if present.

protected set_label(string $label_name) : mixed
Parameters
$label_name : string

The label to assign to the Field context object

validate_port_suffix()

Checks if a given value is a valid socket address (ADDR:PORT) and validates that the port number is valid.

private validate_port_suffix(mixed $value, string $field_name) : string
Parameters
$value : mixed

The value to be validated.

$field_name : string
Return values
string

        
On this page

Search results