-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Validation - permit_empty #830
Comments
Laravel has something similar, the |
The first thing to think can be: Then the required rule is not necessary? Yes. It is. But means required could hold the field and not the value. If is required, then the field MUST be sent. And can be an empty string if is accepted. But the field MUST be sent. |
Yes. I believe that an |
I did not know the |
Related to #614 |
On CI 3, input data sent with blank values are accepted by Form Validation.
For example:
If exists rules to a email field like it:
valid_email|is_unique[users.email]
, the validation accepts blank values, a string''
. Of course''
is not a valid_email. I believe that the validation must fail. But I see that this also occurs in others frameworks, accepting '' as a valid email, if is not set therequired
rule for example.On CI 4 it is not happening. If the user send
''
and exist avalid_email
then the validation show the error. Because''
is not a valid email. I think this a best way to validate.If the user do not send the field email (think about an API) and it have not the
required
rule, then the validation pass. But if he send a blank value the Validation show the error... OK.But a third use case, and common. And, what about if is possible to receive an empty value? Having the
valid_email
rule the Validation do not accept''
.An possible solution, I think, could be an rule to permit this use case. Like a
permit_empty
, that would cancel all other field rules if the value is empty.If what I tried to explain could be confuse, please see:
The text was updated successfully, but these errors were encountered: