question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cross field validation in onChange of a field

See original GitHub issue

There is currently no way to register a validator in a field, that needs to read the value from another field, is there?

I like your validation concept very much and we are using mobx and mobx-react in our project, so your validation framework could fit very well. But one of our reasons why we are looking for a framework anyway, is to easily define cross field validators which should be triggered on changing a specific input field.

Will there be an other method to trigger those validators, besides manually calling the validate function of the surrounding form? Or is there any smart way to structure the FormStates and FieldStates to achieve this? Or is there already a method how validators can read values from other fields?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
basaratcommented, Feb 2, 2017

@alxkhr you can checkout the demo https://formstate.github.io/demos/#cross-field-validation released with 0.11.0 ❤️

0reactions
basaratcommented, Feb 3, 2017

But i wonder why you only re-validate the form if it has no error.

Its a choice I leave to you. Similar to onBlur behavior where you want to validate live vs. validate live starting from on onBlur. You can replace it with !hasFieldError or any other condition you want to tune your UX for.

Plus, i don’t understand the reason why form.hasFormError is necessary anyway

To only show the error if form has an error cause of its validations. Otherwise in case of a field error you would potentially be showing the error against the field & the form. Hope that helps 🌹

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular cross field validation with template forms - Adrian Brand
Angular cross field validation with template forms ... ngOnChanges method to call the onChange method if afterDate is in the changes object.
Read more >
Angular 6 reactive forms, synchronous cross field validation
Question. How do i create a custom synchronous cross field validator? Question on the side. Is it possible to pass in the formControl...
Read more >
Validating form input - Angular
A cross-field validator is a custom validator that compares the values of different fields in a form and accepts or rejects them in...
Read more >
Running Validation with onChange - Salesforce Help
... LWC OmniScripts run validation when a user clicks out of a field by usi... ... Track the Delivery Status of an Outbound...
Read more >
Validation - Formik
Formik is designed to manage forms with complex validation with ease. Formik supports synchronous and asynchronous form-level and field-level validation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found