Open steffendsommer opened 6 years ago
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 ?
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?)?
You're right. That could be done. I even thought of that and forgot it again ... ("yeah yeah, of course you did")
Make the optional validator return a validation error and make it specify what field was (unexpectedly)
nil
.