class LocaleIdentifierValidator extends AbstractValidator (View source)

A validator for locale identifiers.

This validator validates a string based on the expressions of the Flow I18n implementation.

Properties

protected bool $acceptsEmptyValues

Specifies whether this validator accepts empty values.

from  AbstractValidator
protected array $supportedOptions

This contains the supported options, each being an array of:

from  AbstractValidator
protected array $options from  AbstractValidator
protected Result[] $resultStack from  AbstractValidator

Methods

__construct(array $options = [])

Constructs the validator and sets validation options

pushResult()

Push a new Result onto the Result stack and return it in order to fix cyclic calls to a single validator.

popResult()

Pop and return the current Result from the stack and make $this->result point to the last Result again.

Result|null
getResult()

Get the current Result for this validation invocation. Use this inside your isValid() implementation to e.g. merge results together into the current one.

validate(mixed $value)

Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.

void
isValid(mixed $value)

Is valid if the given value is a valid "locale identifier".

void
addError(string $message, int $code, array $arguments = [])

Creates a new validation error object and adds it to $this->errors

array
getOptions()

Returns the options of this validator

bool
isEmpty(mixed $value)

No description

Details

__construct(array $options = [])

Constructs the validator and sets validation options

Parameters

array $options

Options for the validator

Exceptions

InvalidValidationOptionsException

protected Result pushResult()

Since: Flow 4.3

Push a new Result onto the Result stack and return it in order to fix cyclic calls to a single validator.

protected Result popResult()

Since: Flow 4.3

Pop and return the current Result from the stack and make $this->result point to the last Result again.

Return Value

Result

protected Result|null getResult()

Since: Flow 6.0

Get the current Result for this validation invocation. Use this inside your isValid() implementation to e.g. merge results together into the current one.

Return Value

Result|null

Result validate(mixed $value)

Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.

Parameters

mixed $value

The value that should be validated

Return Value

Result

Exceptions

InvalidValidationOptionsException

protected void isValid(mixed $value)

Is valid if the given value is a valid "locale identifier".

Parameters

mixed $value

Return Value

void

protected void addError(string $message, int $code, array $arguments = [])

Creates a new validation error object and adds it to $this->errors

Parameters

string $message

The error message

int $code

The error code (a unix timestamp)

array $arguments

Arguments to be replaced in message

Return Value

void

array getOptions()

Returns the options of this validator

Return Value

array

final protected bool isEmpty(mixed $value)

No description

Parameters

mixed $value

Return Value

bool

true if the given $value is NULL or an empty string ('')