Validator validates user inputs. You can do it by using predefined rule, creating own rule or by regex. Every rule returns true if the input is valid, false otherwise.
The predefined rules:
Just add your function to ValidatorFunctions.php file (Located in /app/classes/
). Every method need to be static and return boolean. Example:
public static function isAdult(int $age): bool {
if ($age < 18) {
return false;
}
return true;
}
Just call function validate:
Validator::validate($input, Validator::RULE_CUSTOM, $min_length, $max_length, $regex);