String validation
Namespace: Sphp \ Validators Predefined errormessage Template formatting parameters:
:value - the string representation of the validated $value
:type - the datatype of the validated $value
:type = "boolean" - for boolean type
:type = "integer" - for integer type
:type = "float" - for float type
:type = "string" - for string type
:type = "array" - for array type
:type = "object" - for object type
:type = "resource" - for resource type
:type = "resource (closed)" - for closed resource type
:type = "NULL" - for nulls
:type = "unknown type" - for unknown types
:strict-type - the strict datatype of the validated $value differs from :type
any object corresponds to the name of the class get_class() results
The Regex validator
The Regex validates the input against the given regular expression. The input
is valid if it matches the given pattern.
The StringLength simply validates the input length. This validator supports three
types of validation
Lower bound validation: the length of the input must be above a given limit.
Upper bound validation: the length of the input must be below a given limit.
Range validation: the length of the input must be between the lower and upper limits.
Predefined Errormessage template formatting parameters:
:min - the minumum allowed string length of the validated $value
:max - the maximum allowed string length of the validated $value
Synopsis
ID for default error message
public const string INVALID Constructs a new validator
public __construct ( int $min = 0 ,
?int $max = null ) Checks whether the validator acts as a range validator or not
public isRangeValidator ( ) : bool
Validates given value
public isValid ( mixed $value ) : bool
Invoke validator as a command
public __invoke ( mixed $value ) : bool