You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a field with the reactive required prop changes its value to false, the subscriber field is still validated to invalid: true.
Expected behavior
A field with reactive prop (i.e. required) must be validated properly when the reactive prop value toggles.
Why
Validation originating from reactive resolver is forced: true
Thus, shouldValidateSync predicate resolves to true
Thus, relevant rules.type.tel rule is executed on an empty field
Resulting into invalid field from the validation.
The reason is that the validation resolver is invoked when it shouldn't. The relation with the forced nature of reactive validation is not correct.
How
importReactfrom'react'import{Form}from'react-advanced-form'import{Input,Checkbox}from'@examples/fields'construles={type: {tel: ({ value })=>/^\+420/.test(value),},}exportdefaultclassFooExampleextendsReact.Component{render(){return(<Formrules={rules}><Inputtype="tel"name="phone"label="Phone"required={({ get })=>get(['some','checked'])}/><Checkboxname="some"label="Accept"/></Form>)}}
Thank you notes to @ludovitkapusta for reporting this issue.
The text was updated successfully, but these errors were encountered:
Removing the forced nature of reactive calls to field validation fixed the issue. If a field state is reset via resetValidationState, then there is no need to force the validation, as the field is treated like it hasn't been validated previously.
This means that the predicates of shouldValidateSync (especially !fieldProps.validatedSync) will resolve properly.
Environment
What
Current behavior
When a field with the reactive
required
prop changes its value tofalse
, the subscriber field is still validated toinvalid: true
.Expected behavior
A field with reactive prop (i.e.
required
) must be validated properly when the reactive prop value toggles.Why
forced: true
shouldValidateSync
predicate resolves totrue
rules.type.tel
rule is executed on an empty fieldThe reason is that the validation resolver is invoked when it shouldn't. The relation with the forced nature of reactive validation is not correct.
How
Thank you notes to @ludovitkapusta for reporting this issue.
The text was updated successfully, but these errors were encountered: