Open halfer opened 6 years ago
There isn't an implementation for validate for emails, so although an empty string will be correctly filtered to null, it will validate as true, which is not desirable.
validate
null
true
Repro code:
$filter = \Filterus\Filter::factory('email'); $result = $filter->filter(''); var_dump($result); // Returns NULL, correct $ok = $filter->validate(''); echo $ok ? 'Passed' : 'Failed'; // Incorrectly returns Passed
A solution for now is to use a chain, like so:
$filter = \Filterus\Filter::chain('email', 'string,min:1'); $result = $filter->filter(''); var_dump($result); // Returns NULL, correct $ok = $filter->validate(''); echo $ok ? 'Passed' : 'Failed'; // Correctly returns Failed
There isn't an implementation for
validate
for emails, so although an empty string will be correctly filtered tonull
, it will validate astrue
, which is not desirable.Repro code:
A solution for now is to use a chain, like so: