shakacode / re-formality

Form validation tool for reason-react
https://re-formality.now.sh
MIT License
244 stars 35 forks source link

Generalize payload of `FormStatus.SubmissionFailed` constructor #48

Closed alex35mil closed 5 years ago

alex35mil commented 5 years ago

I'm thinking of making payload of FormStatus.SubmissionFailed constructor generic, i.e. turn this:

module FormStatus = {
  type t('field, 'message) =
    | Editing
    | Submitting
    | Submitted
    | SubmissionFailed(list(('field, 'message)), option('message));
};

into this:

module FormStatus = {
  type t('error) =
    | Editing
    | Submitting
    | Submitted
    | SubmissionFailed('error);
};

I found that I never (literally, zero times) used current payload but do use domain specific error types all the time and put those in component state. With generic version it's still possible to use currently hardcoded type by defining it in user land but it would make it more flexible for other use-cases. I wonder how others use it (if use it at all).

alex35mil commented 5 years ago

Downside is that it will require addition of a type to a form config... 🤔