LengthValidationRule
extends BaseRule
in package
Validates that the length of a content is smaller than the indicated minimum length. This validates only data as strings which may cause unexpected behavior if you try to test the length of an array.
Tags
Table of Contents
- $extendedMessage : string
- Additional information given to the user in case the validation did not succeed. This message can hold additional infos on how to solve the error.
- $max : int
- The maximum length a string passed to this element can have for the test to be passed successfully.
- $message : string
- A message the validation error generated by this object should carry to give the end user information about the reason his input was rejected.
- $min : int
- The minimum length a string passed to this element must have for the test to be passed successfully.
- __construct() : mixed
- Creates a maximum length validation rule. This will provide a way to test whether a string is longer than allowed before using or storing it.
- getExtendedMessage() : mixed
- getMessage() : mixed
- test() : ValidationError|bool
- Tests a value with this validation rule. Returns the errors detected for this element or boolean false on no errors.
Properties
$extendedMessage
Additional information given to the user in case the validation did not succeed. This message can hold additional infos on how to solve the error.
private
string
$extendedMessage
$max
The maximum length a string passed to this element can have for the test to be passed successfully.
private
int
$max
$message
A message the validation error generated by this object should carry to give the end user information about the reason his input was rejected.
private
string
$message
$min
The minimum length a string passed to this element must have for the test to be passed successfully.
private
int
$min
Methods
__construct()
Creates a maximum length validation rule. This will provide a way to test whether a string is longer than allowed before using or storing it.
public
__construct(int $min, int $max, string $message[, string $extendedMessage = '' ]) : mixed
Parameters
- $min : int
- $max : int
- $message : string
- $extendedMessage : string = ''
Return values
mixed —getExtendedMessage()
public
getExtendedMessage() : mixed
Return values
mixed —getMessage()
public
getMessage() : mixed
Return values
mixed —test()
Tests a value with this validation rule. Returns the errors detected for this element or boolean false on no errors.
public
test(mixed $value) : ValidationError|bool
Parameters
- $value : mixed