class MaximumLengthValidator extends AbstractTranslatableValidator (View source)

Validate the length of a string.

Constants

E_TOO_LONG

Too long.

Properties

protected array $translatable_requirements from  AbstractTranslatableValidator
protected array $translatable_errors from  AbstractTranslatableValidator
protected int $maximum_length

The maximum length.

Methods

setRequirementString(int $code, string|Closure $message)

Set the requirement string to a mixed value.

setErrorString(int $code, string|Closure $message)

Set the error string to a string or to a closure.

string[]
getRequirementStrings()

Get the validator requirements in the form of an array keyed by it's respective error code.

string|mixed
getErrorString(int $code, mixed $value, mixed $default = null)

Get an error string given a code and a passed value.

bool
isTranslatableStringValueValid(Closure|string|mixed $value)

Check to see if $value a valid stand in for a translatable string.

__construct(int $maximum_length)

MaximumLengthValidator constructor.

int
getMaximumLength()

Get the maximum length allowed.

setMaximumLength(int $maximum_length)

Set the maximum length allowed.

bool
isValid(mixed $mixed, ArrayAccess $error = null)

Is this mixed value valid.

Details

setRequirementString(int $code, string|Closure $message)

Set the requirement string to a mixed value.

Parameters

int $code

The error code

string|Closure $message

Either a plain string, or a closure that returns a string

See also

TranslatableValidatorInterface::setRequirementString

setErrorString(int $code, string|Closure $message)

Set the error string to a string or to a closure.

Parameters

int $code

The error code

string|Closure $message

Either a plain string, or a closure that returns a string

See also

TranslatableValidatorInterface::setErrorString

string[] getRequirementStrings()

Get the validator requirements in the form of an array keyed by it's respective error code.

Return Value

string[]

See also

ValidatorInterface::getRequirementStrings

protected string|mixed getErrorString(int $code, mixed $value, mixed $default = null)

Get an error string given a code and a passed value.

Parameters

int $code
mixed $value
mixed $default

Return Value

string|mixed

Returns a string or $default

protected bool isTranslatableStringValueValid(Closure|string|mixed $value)

Check to see if $value a valid stand in for a translatable string.

Parameters

Closure|string|mixed $value

Return Value

bool

__construct(int $maximum_length)

MaximumLengthValidator constructor.

Parameters

int $maximum_length

int getMaximumLength()

Get the maximum length allowed.

Return Value

int

setMaximumLength(int $maximum_length)

Set the maximum length allowed.

Parameters

int $maximum_length

bool isValid(mixed $mixed, ArrayAccess $error = null)

Is this mixed value valid.

Parameters

mixed $mixed

Can be any value

ArrayAccess $error

Return Value

bool

Exceptions

InvalidArgumentException

See also

ValidatorInterface::isValid