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

Cannot(?) validate that either field A or field B be filled. #72

Closed
Mamsaac opened this issue Jun 21, 2013 · 4 comments · Fixed by #78
Closed

Cannot(?) validate that either field A or field B be filled. #72

Mamsaac opened this issue Jun 21, 2013 · 4 comments · Fixed by #78
Assignees

Comments

@Mamsaac
Copy link

Mamsaac commented Jun 21, 2013

Validation logic for requiring one of either fields to be filled, but not requiring both necessarily has to be done outside of the form definition.

While not a big deal, since it feels like the purpose of validators is to save the programmer to add extra validation logic outside from form creation, it would be nice to have the possibility to define a validator that gets executed when field.data is empty and the field is not required.

@ljharb
Copy link
Collaborator

ljharb commented Jun 21, 2013

Can you give me an example of a use case for this? Typically whenever I've seen this, it's because the schema is in desperate need of a refactor.

@Mamsaac
Copy link
Author

Mamsaac commented Jun 23, 2013

User has to define emergency contacts for a given situation. We accept require the user giving either the e-mail or the cellphone number of the contact. If both are provided, the contact is done via both ways; if only the e-mail or the cellphone is given, then only via either way they will be contacted. If non is given, the emergency contact is not accepted, since there's no way to contact him/her.

@ljharb
Copy link
Collaborator

ljharb commented Jun 23, 2013

Interesting! I'll have to think about what sort of API would make sense for that, and how much complexity that would add to forms. If it can be added simply, then awesome, otherwise I'll end up suggesting that you just check that yourself :-)

@Mamsaac
Copy link
Author

Mamsaac commented Jun 23, 2013

At the moment I do check it out myself.

I'm full of work at the moment, else I would love to contribute to this. If I find myself with a free day, be sure I will try to contribute to this :)

I'm looking forward to the nested forms being on stable branch! thanks for all the good work.

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

Successfully merging a pull request may close this issue.

2 participants