Skip to content

Offer non-immediate validation in Fable.Simple.Form #42

@mattgallagher92

Description

@mattgallagher92

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 as ValidateOnBlur)
  • ValidateOnBlurOnly (trigger only after blur, not while still focused on a field)
  • ValidateOnSubmitThenImmediately (currently known as ValidateOnSubmit)
  • 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions