pfSense-pkg-RESTAPI

RegexValidator extends Validator
in package

Defines a Validator that checks if a given value matches a specified regex pattern.

Table of Contents

Properties

$allowed_keywords  : array<string|int, mixed>
$error_msg  : string
$field_context  : Field|null
$invert  : bool
$model_context  : Model|null
$pattern  : string

Methods

__construct()  : mixed
Constructs the Validator object.
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
Validates a specified value against our regex pattern.
set_label()  : mixed
Sets a label on the assigned $field_context if present.

Properties

$allowed_keywords

public array<string|int, mixed> $allowed_keywords = []

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

Constructs the Validator object.

public __construct(string $pattern[, bool $invert = false ][, array<string|int, mixed> $allowed_keywords = [] ][, string $error_msg = '' ]) : mixed
Parameters
$pattern : string

The regex pattern to validate the value against.

$invert : bool = false

Invert the context of the pattern. If true, any value that does NOT match the pattern will be considered valid. This does not invert the context of $allowed_keywords.

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

An array of values that should be allowed even if they do not match the pattern.

$error_msg : string = ''

An optional error message to include when validation fails. This helps provide context to the regex pattern.

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

Validates a specified value against our regex pattern.

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

The incoming value to be validated.

$field_name : string = ''

The name of the field being validated.

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


        
On this page

Search results