class MaximumLengthValidator extends AbstractTranslatableValidator (View source)

Validate the length of a string.

\@package Concrete\Core\Validator\String

Constants

E_TOO_LONG

Too long

Properties

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

Methods

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

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

bool
isTranslatableStringValueValid($value)

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

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

Set the requirement string to a mixed value Closure format: function(TranslatableValidatorInterface $validator, int $code): string.

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

Set the error string to a string or to a closure Closure format: function(TranslatableValidatorInterface $validator, int $code, mixed $passed): string.

string[]
getRequirementStrings()

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

__construct(int $maximum_length)

MaximumLengthValidator constructor.

int
getMaximumLength()

Get the maximum length allowed.

setMaximumLength(int $maximum_length)

Set the maximum length.

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

Is this mixed value valid.

Details

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

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

Parameters

$value

Return Value

bool

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

Set the requirement string to a mixed value Closure format: function(TranslatableValidatorInterface $validator, int $code): string.

Parameters

int $code

The error code

string|Closure $message

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

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

Set the error string to a string or to a closure Closure format: function(TranslatableValidatorInterface $validator, int $code, mixed $passed): string.

where $passed is whatever was passed to ValidatorInterface::isValid

Parameters

int $code

The error code

string|Closure $message

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

string[] getRequirementStrings()

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

Example: [ self::E_TOO_SHORT => 'Must be at least 10 characters' ]

Return Value

string[]

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

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

Invalid mixed value type passed.