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

Don't validate field when it's target gets filled. #1765

Closed
alanaasmaa opened this issue Dec 19, 2018 · 1 comment · Fixed by #1915
Closed

Don't validate field when it's target gets filled. #1765

alanaasmaa opened this issue Dec 19, 2018 · 1 comment · Fixed by #1915
Labels
✨ enhancement a "nice to have" feature ☔ has workaround this issue has a workaround

Comments

@alanaasmaa
Copy link

Is your feature request related to a problem? Please describe.
Hi,

I have a custom validator that uses a target.

For example I got age field with rule required.
And second field that is select box and uses age as target for custom rule.
Lets say for example Confirm age with rule required|confirm:age

Now when i change the first age field that only has required rule. It also runs a validation for Confirm age field and marks this invalid. When there is big form with many fields and many refs the form starts to get very red even when you haven't filled half of it.

So on my example it runs required validation for Confirm age field. And prints error This field is required or something.

Describe the solution you'd like
I would like to disable the validation for ref.

Describe alternatives you've considered
I was thinking if i can edit my custom rule. But it wont be triggered.

Other alternative would be to create custom event that removes an error when second field does not have a value.

@logaretm
Copy link
Owner

logaretm commented Dec 19, 2018

I see the use case here. I would argue that instead of not validating when the target is changed, only validate the field if it has been manipulated by the user.

Validating the field again is necessary for the whole premise around the target-based or cross-field validation to work.

Slightly tweaking this to only validate the targets when they have been validated before (either manual by calling validate() or by user interaction) would make it acceptable for your use-case without risking incorrect validation state.

As a workaround, you could use or create rules similar to is which do not depend on cross-field validation, but on an actual value.

@logaretm logaretm added ✨ enhancement a "nice to have" feature ☔ has workaround this issue has a workaround labels Dec 19, 2018
logaretm added a commit that referenced this issue Mar 11, 2019
This PR forces the validation provider and the directive to not validate the cross-field targets until they have been interacted with or if validation was triggered manually at least once.

This solves the "aggressive" behavior when the user has only interacted with one of the two confirmed inputs for the first time.

closes #1902, closes #1869, closes #1765
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement a "nice to have" feature ☔ has workaround this issue has a workaround
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants