mirror of
https://github.com/Respect/Validation.git
synced 2024-06-03 14:22:16 +02:00
689026fc7b
The `filter_var` function is more of a sanitizer, but we as a validation library do not care for that use case. We should treat its sanitizings as a signal for checking if the type after sanitization matches the option provided. This fixes #1387
1 KiB
1 KiB
FilterVar
FilterVar(int $filter)
FilterVar(int $filter, mixed $options)
Validates the input with the PHP's filter_var() function.
v::filterVar(FILTER_VALIDATE_EMAIL)->validate('bob@example.com'); // true
v::filterVar(FILTER_VALIDATE_URL)->validate('http://example.com'); // true
v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->validate('http://example.com'); // false
v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->validate('http://example.com/path'); // true
v::filterVar(FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)->validate('webserver.local'); // true
v::filterVar(FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)->validate('@local'); // false
Categorization
- Miscellaneous
Changelog
Version | Description |
---|---|
2.3.0 | v::filterVar(FILTER_VALIDATE_INT)->validate(0) is no longer false |
2.0.15 | Allow validating domains |
0.8.0 | Created |
See also: