validate::request()
Retrieve and validate an HTTP GET or POST query parameter value. If a GET and POST query parameter exist with the same key, the POST parameter will be used.
Prototype
string request(string $key, array $validations, string $invalid_message = NULL)
Parameters
- key - Name of the parameter to retrieve.
- validations - An array of validate strings or object/method pairs.
- invalid_message - Message to log in validation error if the value does not pass all validations.
Return
Returns the value, even if it does not validate. Check validate::valid() to determine if the value is valid.
Example
$validate = new \io_comand_web\validate();
$validate->request('email',
['trim', 'required', 'email'],
'Invalid email address'
);
if($validate->valid()) {
echo('Email is valid.');
}