-
-
Notifications
You must be signed in to change notification settings - Fork 11
Description
The current validation strategies offered in Fable.Form.Simple are ValidateOnBlur and ValidateOnSubmit. Based on their names, I assumed that they would only validate when a field is blurred or the form is submitted. However, the behaviour instead seems to be that validation is first triggered after blur/submit, but is then triggered after every subsequent change to a field. I would like an option that results in validation only being triggered on submit.
I propose that the following would be suitable cases for the Fable.Form.Simple.Form.View.Validation type:
ValidateImmediately(trigger validation after every field state change)ValidateOnBlurThenImmediately(currently known asValidateOnBlur)ValidateOnBlurOnly(trigger only after blur, not while still focused on a field)ValidateOnSubmitThenImmediately(currently known asValidateOnSubmit)ValidateOnSubmitOnly(trigger only when submitting, not before)
Another possible case could be ValidateOnSubmitThenOnBlur, but my guess is that that wouldn't be very popular.
ValidateOnBlur and ValidateOnSubmit could remain in the library for now, but be marked as deprecated, prompting users to swtich to the ...ThenImmediately case to preserve behaviour.
Assuming that you're happy with the design proposed above, I'd be happy to investigate the ValidateOnSubmitOnly case, and hopefully make a PR. The other cases could be left for other contributors (or not implemented at all if there's no demand).