-
Notifications
You must be signed in to change notification settings - Fork 376
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
How to add validation without making field required? #185
Comments
Absolutely right, If the field is empty then it tries to validate the value. There should be a condition to check if the field does not contains RequiredRule then do not validate field with blank values. |
Yes this seems to be issue I have empty fields without RequiredRule throwing errors so I think now there is only possibility to check by type of errors? |
Hello @RajatJain4061 |
@RajatJain4061, I also need this fixed. Can you fix it? |
@josueruiz7 @felipe-azevedo I will fix this ASAP within next 2 days |
@RajatJain4061 any news on this? |
@RajatJain4061 hey, man. Sorry to bother again, but I really need this. |
@RajatJain4061 any news? thanks. |
You can fix that by checking value is empty (return true) in the validate func in RegexRule |
@phuongnguyen2359 I expected the framework to do this. I have too many fields and I don't want to check each one for a value before validating. |
@phuongnguyen2359 Also, this affects every Rule, not just Regex. |
Hopefully I’ll fix this on this Sunday. Sorry for getting delayed.
On Fri, 17 Aug 2018 at 10:18 PM, felipe-azevedo ***@***.***> wrote:
@phuongnguyen2359 <https://github.com/phuongnguyen2359> Also, this
affects every Rule, not just Regex.
For example if I have minLength and maxLength validations and the field is
not required, empty would be an acceptable value, but it's not because it
will violate the minLength.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#185 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ23SakywkYOBP_WuLCLbp_ptt5fVtPJks5uRvPEgaJpZM4OBRxO>
.
--
|
Thanks, @RajatJain4061 |
If you think it will work then you can make the necessary changes and
create a pull request. If everything goes well then I’ll merge your PR.
On Fri, 17 Aug 2018 at 10:36 PM, felipe-azevedo ***@***.***> wrote:
Thanks, @RajatJain4061 <https://github.com/RajatJain4061>
If you want a suggestion, I'd add a property to the Validator's init to
allow empty for non-required fields. If that's set to true, when you
validate a field that's not required and it's empty, all validations should
return true, i.e. all rules should be ignored.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#185 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ23SRsEMLu4XZTlroVYO2Za9IToFQggks5uRvgTgaJpZM4OBRxO>
.
--
Thanks and Regards,
|
@felipe-azevedo if the framework do this. it's cool still wait for it. In my case, I just need email field can be empty so doing this just affects email rule |
@phuongnguyen2359 I have big forms, 15, 20 fields all with validations. Most of the fields are required, but some are not, and to avoid having to create an exception for each of the affected rules, I wanted to fix this across the board. |
Ok I’ll try to do it myself
On Fri, 17 Aug 2018 at 11:04 PM, felipe-azevedo ***@***.***> wrote:
@phuongnguyen2359 <https://github.com/phuongnguyen2359> I have big forms,
15, 20 fields all with validations. Most of the fields are required, but
some are not, and to avoid having to create an exception for each of the
affected rules, I wanted to fix this across the board.
@RajatJain4061 <https://github.com/RajatJain4061> this was my suggestion
for you to fix it, man. I don't have time to fix it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#185 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ23Sf_P09osn02P7fATO900phd4oj8gks5uRv7DgaJpZM4OBRxO>
.
--
Thanks and Regards,
*Rajat Jain*
*(Software Engineer - iOS & PHP)*
Mob:8104614061
LinkedIn : https://www.linkedin.com/in/rajat-jain-945317ab
Skype Id: rajatjain4061
|
@RajatJain4061 hi, any news on this? |
@RajatJain4061 can you fix this please? |
@RajatJain4061, @davepatterson |
Any news for this issue? I also need the fix. Thanks. |
It seems it's not possible to set a validation rule on a field without making it required. i.e. - Phone number should not be required but if something is entered, validate it
The text was updated successfully, but these errors were encountered: