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
The dependent option in fields config should be re-thought as the intended behaviour isn't clear from the option name. To me dependent suggests that the field will be included in the form depending on a previous answer given, not that all validators will only be executed depending on a previous answer. It should be noted in the documentation that only fields that are already set (previous steps or editing) will be taken into account.
I would suggest either moving the dependent config option to each individual validator:
I can see how this could be confusing. dependent fields are those used in progressive reveals/disclosures. This property is used to decide if a field should be validated. I thought it only took effect on the current form values and not all values.
You're right - i didn't dig too deeply - it only takes current step values into account. In this case I'd suggest renaming it to validateDependentOn or validateIf or something similar? We have a requirement to include/exclude a field on a step/form dependent on a previous field value, and this to me seems more fitting to the term dependent
https://github.com/UKHomeOffice/passports-form-controller/blob/master/lib/validation/index.js#L36-L50
The
dependent
option in fields config should be re-thought as the intended behaviour isn't clear from the option name. To medependent
suggests that the field will be included in the form depending on a previous answer given, not that all validators will only be executed depending on a previous answer. It should be noted in the documentation that only fields that are already set (previous steps or editing) will be taken into account.I would suggest either moving the dependent config option to each individual validator:
or perhaps renaming it to
validateIf
or something similar.The text was updated successfully, but these errors were encountered: