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

Multi field validation (i.e. one of must be present) can result in incorrect isValid state #192

Open
nickschot opened this issue Feb 7, 2019 · 1 comment

Comments

@nickschot
Copy link
Contributor

This might be more of a feature request than a bug (at least with the provided validators).

I have implemented a validator which checks for presence OR for the presence of other fields (so at least one of the fields must be "present" for the validator to pass). Currently there is no way to call validation for these other fields as the actual changeset is not passed to the validator function (just the changes and the model).

The only "workaround" right now is to call validate on the main changeset validating all fields, but this means that before that happens, the isValid state is incorrect (and errors for said fields might be present on the changeset).

This is likely also an issue for the validator proposed in #189 / #191

@nickschot
Copy link
Contributor Author

Example:

  • Two fields of which one is currently in an invalid state.
  • The other field is filled by a user and changes to valid state.
  • The other field remains invalid even though it passes validation
  • Calling changeset.validate() turns everything valid.

Ideally you'd be able to call changeset.validate('my-other-field') instead of needing to validate the entire changeset.

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

No branches or pull requests

1 participant