V2:Validators
From PhpInputValidator
Validators are extra set of validations you can run against input. These are passed in using an array on the last parameter with the get function. Here is an example:
Contents |
default (mixed)
The default value to be passed back if the input is not validated
invalid_values (mixed array)
This is an array of values you require the value to not be one of. For example you expect a passed in value to not be red, blue, or green.
In this example if the variable is equal to yellow it will return yellow. If the value is red it will return null;
min_between (int)
The minimum value a number can be.
min_length (string)
The minimum lengh of a string.
max_between (int)
The max value a number can be.
max_length (string)
The maximum lengh of a string.
of (Types)
This works in conjunction with the type array to validate the array values for this type. For example:
In this example if $_POST['bar'] is an array and each element is an int it will pass back that array. It is a hard task to find proper writing service, there is always a risk to be cheated or at least to get unsatisfactory grade for passing low quality paper. I have tried tons of them, and, to my mind, this is the best essay writing service. Please take it into consideration because I think that it�s better to try it once than waste your time and money on unprofessional writing companies. If not it will pass back the default.
purify (_PIV_VAR_CLEAN, _PIV_VAR_PURIFY)
What type of html purification to use against a string. This only applies when the type is set to string.
_PIV_VAR_CLEAN = Strip any html characters from the string
_PIV_VAR_PURIFY = Use HTMLPurifier if installed
regex_false (preg_match regex)
A regular expression to be used in a preg_match and if the return is true it will fail
regex_true (preg_match regex)
A regular expression to be used in a preg_match and if the return is false it will fail
valid_values (mixed array)
This is an array of values you require the value to be one of. For example you expect a passed in value to be either red, blue, or green.
Defaults
| Option | Value |
|---|---|
| default | null |
| invalid_values | null |
| min_between | null |
| min_length | null |
| max_between | null |
| max_length | null |
| of | null |
| purify | _PIV_VAR_CLEAN |
| regex_false | null |
| regex_true | null |
| valid_values | null |