\Greg\Support\Validation\Validation validate parameters against validators.
Throws: \Greg\Support\Validation\ValidationException.
- addValidators - Add validators;
- addPrefix - Add a prefix or an array of prefixes;
- addSuffix - Add a suffix or an array of suffixes;
- validate - Validate parameters.
Methods description is under construction.
- dateTimeFrom - Validate a
DateTimeto be grater than anotherDateTime; - dateTimeTo - Validate a
DateTimeto be less than anotherDateTime; - email - Validate an email address;
- enum - Validate a value to exists in a stack;
- equal - Validate a value to be equal with another value;
- int - Validate a value to be an integer;
- length - Validate a string length;
- maxLength - Validate a string maximum length;
- minLength - Validate a string minimum length;
- max - Validate a number to be less than another number;
- min - Validate a number to be greater than another number;
- required - Validate a value to be not empty.
\Greg\Support\Validation\ValidatorStrategy is a strategy for custom validators.
Example:
class CustomValidator implements \Greg\Support\Validation\ValidatorStrategy
{
public function validate($value, array $values = [])
{
// @todo: validation strategy
}
}Validate a value.
validate(mixed $value, array $values = []): boolean;$value - The value;
$values - Other values.