Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email validation doesn't work on an empty string #14

Open
halfer opened this issue Mar 11, 2018 · 0 comments
Open

Email validation doesn't work on an empty string #14

halfer opened this issue Mar 11, 2018 · 0 comments

Comments

@halfer
Copy link

halfer commented Mar 11, 2018

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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant