Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Make optional validator return the key that is nil #15

Open
steffendsommer opened this issue Feb 8, 2018 · 3 comments
Open

Make optional validator return the key that is nil #15

steffendsommer opened this issue Feb 8, 2018 · 3 comments

Comments

@steffendsommer
Copy link
Contributor

Make the optional validator return a validation error and make it specify what field was (unexpectedly) nil.

@siemensikkema
Copy link
Contributor

I think this should be handled for all validation errors, not just those from the OptionalValidator.

How about something like this:

FormField(validator: MyValidator().prefixingErrors(with: “Error validating value for ‘\(myKey):))

or

MyValidator().indicateThatErrorsAreForKey(for: myKey)

I'd like to find a better name. Any ideas @steffendsommer ?

@steffendsommer
Copy link
Contributor Author

I agree that it would be nice to have this for all validators. Would it make sense to have this responsibility on the FormField since it has the key already (or maybe that's optional?)?

@siemensikkema
Copy link
Contributor

You're right. That could be done. I even thought of that and forgot it again ... ("yeah yeah, of course you did")

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

No branches or pull requests

2 participants