File src/class/Utility/InputValidator.php
class Lia\Utility\InputValidator
Simple class for validating user inputs
See source code at /src/class/Utility/InputValidator.php
Constants
Properties
-
protected array $rules = [];
Methods
-
public function validate(arraystring $rules_list, mixed $input_value, string $input_name = null, mixed &$ref null): bool -
public function add_rule(string $rule_name, callable $callable, bool $overwrite_existing = false)Add a rule -
public function has_rule(string $rule_name): bool -
public function get_failure_message(string $rule_name): stringbool -
public function is_string(mixed $value)$value must be a string peris_string($value) -
public function is_number(mixed $value)$value must be a number peris_numeric($value) -
public function is_int(mixed $value)$value must be an int. Typecasts to int if value is a string containing int. -
public function is_alnum(mixed $value)$value must be alphanumeric, perctype_alnum($value) -
public function is_oneof(mixed $value, string $target_values)$value must be in the $target_values list. $target_values are comma separated -
public function is_maxlen(mixed $value, string $length)$value must be a string longer than $length -
public function is_minval(mixed $value, string $intval)$value must be >= $intval -
public function is_nohtml(mixed $value, string $should_strip)(UNTESTED) $value must not contain html or htmlspecialchars. If you pass 'strip', thenstrip_tags()&htmlspecialchars()will modify value. -
public function is_safehtml(mixed $value, string $should_strip)(UNTESTED) $value must only contain safe html tags. If you pass 'strip', then value is set tostrip_tags($value, ALLOWED_TAGS). (no script or style. See function definition for full list)