Documentation

Validator

Validator handles backend validation of all your data, where you need.

Methods

  • Validator::validate($input, $rules)
    Validate an associative array of values.
    $input: an associative array where the key correspond the name of the value in input.
    $rules: an associative array where the name correspond the type of field to validate.
    This method return boolean: true in case of validate success, otherwise return an array containing the name of field that not pass the validation.
  • Validator::validateFormValues($input, $rules)
    In $input put your form data, and $rules contain for every input the type of rule. Like this: Format for input:
    $input[ 0 => ["values" => ["your_value"]],
    1 => ["values" => ["check_1","check_2"]] ]

    Format for rule:
    $rules[ 0 => ["required|string"],
    1 => ["Required|Min:1|Max:3"] ]

    Here is the list of rule you can use in your validator:
    Required, String, Integer, Float, Min, Max, In
  • Validator::string($input)
    Use this method to validate an field that can only accept string as input
  • Validator::onlyChars($input)
    Use this method to validate an field that can only accept char as input
  • Validator::onlyCharsWithSpace($input)
    Use this method to validate an field that can only accept char with space as input
  • Validator::onlyCharNumbersUnderscore($input) Use this method to validate an field that can only accept char with number and underscore as input
  • Validator::address($input)
    Use this method to validate an field that can only accept address type as input
  • Validator::operators($rule)
    Use this method to validate an field that can only accept operator as input like: "like", "not like", "<>", "=", "<", "<=", ">", ">=".
  • Validator::varchar_max_length($input)
    Use this method to validate an field that can only accept max string length setup into env as input
  • Validator::numeric($input)
    Use this method to validate an field that can only accept number as input
  • Validator::alphanumeric($input)
    Use this method to validate an field that can only accept number and char as input
  • Validator::integer($input)
    Use this method to validate an field that can only accept integer as input
  • Validator::float($input)
    Use this method to validate an field that can only accept float as input
  • Validator::in($elem, $array)
    Use this method to validate an field that check if in the array the element is exists or not.
  • Validator::email($input)
    Use this method to validate an field that can only accept email as input
  • Validator::phone($input)
    (TODO)Use this method to validate an field that can only accept phone as input
  • Validator::password_login($password)
    Use this method to validate an field that can only accept password as input
  • Validator::password($password)
    Use this method to validate an field that can only accept password as input
  • Validator::strongPassword($password)
    Use this method to validate an field that check if the password is a strong password
  • Validator::username($username)
    Use this method to validate an field that can only accept username format as input
  • Validator::filename($filename)
    (TODO)
  • Validator::required($input, $array)
    Use this method to check if the input is in array or not
  • Validator::setError($key,$message)
    This method set error for Validator class.
  • Validator::hasError()
    This method check if Validator class has error