Skip to content

Latest commit

 

History

History
62 lines (45 loc) · 1.78 KB

Validation.md

File metadata and controls

62 lines (45 loc) · 1.78 KB

Validation Documentation

\Greg\Support\Validation\Validation validate parameters against validators.

Throws: \Greg\Support\Validation\ValidationException.

Table of contents:

Methods:

Methods description is under construction.

Validators

  • dateTimeFrom - Validate a DateTime to be grater than another DateTime;
  • dateTimeTo - Validate a DateTime to be less than another DateTime;
  • 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.

Validator Strategy

\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

Validate a value.

validate(mixed $value, array $values = []): boolean;

$value - The value;
$values - Other values.