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

How to make required validators run after the user finished interacting with both fields? #556

Open
Cohaven opened this issue Feb 28, 2022 · 0 comments

Comments

@Cohaven
Copy link

Cohaven commented Feb 28, 2022

Describe the problem statement?

I have the following form controls in my form group:

rangeFrom: new FormControl(null, {
  validators: [
    RxwebValidators.required({ conditionalExpression: (x) => x.rangeTo }),
    RxwebValidators.numeric({ acceptValue: NumericValueType.Both, allowDecimal: true }),
  ],
}),
rangeTo: new FormControl(null, {
  validators: [
    RxwebValidators.required({ conditionalExpression: (x) => x.rangeFrom }),
    RxwebValidators.numeric({ acceptValue: NumericValueType.Both, allowDecimal: true }),
    RxwebValidators.greaterThan({ fieldName: 'rangeFrom' }),
  ],
}),

Currently, the required validators show an error when you start typing into one of the fields.

The expected solution you would like

I want to know how I can adjust my form to make the required validators only run once the user stops interacting with the two fields. It can be annoying to see an error that rangeTo is required before the user had the chance to update both fields. I would need to incorporate the focusout event into this somehow.

Package version

@rxweb/reactive-form-validators: 2.1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants