rex_validator
in package
Uses
rex_factory_trait
Validator class.
Tags
Table of Contents
Methods
- add() : $this
- Adds a validation rule.
- addRule() : $this
- Adds a validation rule.
- custom() : bool
- Checks the value by using the given callable.
- email() : bool
- Checks whether the value is an email address.
- factory() : static
- Factory method.
- getMessage() : string|null
- Returns the message.
- getRules() : array<int, rex_validation_rule>
- isValid() : bool
- Checks whether the given value matches all added validators.
- match() : bool
- Checks whether the value matches the given regex.
- max() : bool
- Checks whether the value is equal or lower than the given max value.
- maxLength() : bool
- Checks whether the value has the given max value.
- min() : bool
- Checks whether the value is equal or greater than the given min value.
- minLength() : bool
- Checks whether the value has the given min length.
- notEmpty() : bool
- Checks whether the value is not empty.
- notMatch() : bool
- Checks whether the value does not match the given regex.
- type() : bool
- Checks whether the value is from the given type.
- url() : bool
- Checks whether the value is an URL.
- values() : bool
- Checks whether the value is one of the given valid values.
- __construct() : mixed
Methods
add()
Adds a validation rule.
public
add(string $type[, string|null $message = null ][, mixed $option = null ]) : $this
Parameters
- $type : string
-
Validator type (any static method name of this class)
- $message : string|null = null
-
Message which is used if this validator type does not match
- $option : mixed = null
-
Type specific option
Tags
Return values
$thisaddRule()
Adds a validation rule.
public
addRule(rex_validation_rule $rule) : $this
Parameters
- $rule : rex_validation_rule
Tags
Return values
$thiscustom()
Checks the value by using the given callable.
public
custom(string $value, callable(string): bool $callback) : bool
Parameters
- $value : string
- $callback : callable(string): bool
Return values
boolemail()
Checks whether the value is an email address.
public
email(string $value) : bool
Parameters
- $value : string
Return values
boolfactory()
Factory method.
public
static factory() : static
Return values
staticgetMessage()
Returns the message.
public
getMessage() : string|null
Return values
string|nullgetRules()
public
getRules() : array<int, rex_validation_rule>
Return values
array<int, rex_validation_rule>isValid()
Checks whether the given value matches all added validators.
public
isValid(string $value) : bool
Parameters
- $value : string
Return values
boolmatch()
Checks whether the value matches the given regex.
public
match(string $value, string $regex) : bool
Parameters
- $value : string
- $regex : string
Return values
boolmax()
Checks whether the value is equal or lower than the given max value.
public
max(string $value, int $max) : bool
Parameters
- $value : string
- $max : int
Return values
boolmaxLength()
Checks whether the value has the given max value.
public
maxLength(string $value, int $maxLength) : bool
Parameters
- $value : string
- $maxLength : int
Return values
boolmin()
Checks whether the value is equal or greater than the given min value.
public
min(string $value, int $min) : bool
Parameters
- $value : string
- $min : int
Return values
boolminLength()
Checks whether the value has the given min length.
public
minLength(string $value, int $minLength) : bool
Parameters
- $value : string
- $minLength : int
Return values
boolnotEmpty()
Checks whether the value is not empty.
public
notEmpty(string $value) : bool
Parameters
- $value : string
Return values
boolnotMatch()
Checks whether the value does not match the given regex.
public
notMatch(string $value, string $regex) : bool
Parameters
- $value : string
- $regex : string
Return values
booltype()
Checks whether the value is from the given type.
public
type(string $value, string $type) : bool
Parameters
- $value : string
- $type : string
Tags
Return values
boolurl()
Checks whether the value is an URL.
public
url(string $value) : bool
Parameters
- $value : string
Return values
boolvalues()
Checks whether the value is one of the given valid values.
public
values(string $value, array<string|int, mixed> $validValues) : bool
Parameters
- $value : string
- $validValues : array<string|int, mixed>
Return values
bool__construct()
protected
__construct() : mixed