We would like to remove validations from Frig.
There are two types of errors/validations in Frig:
- Errors set programatically in the
<Form errors={}> attribute, typically server-side errors (but could be anything)
- Field-level, client-side validation errors set automatically by Frig validations, a.k.a. "Frig validations"
As for "Frig validations", users don't have a lot of control over these. We provide three very basic validations, required, min, and max. There is no support for custom validations.
"Frig validations" run in a way that is inconsistent with the <Form errors={}> attribute.
When a field changes, we run these validations. If there is an error, we display the error message next to the field. <Submit> will simply refuse to call Form's onSubmit if there are any errors.
There is no way to programatically access or manipulate these field-level, client-side errors. They also don't cascade up to the <FormErrorList> object. A form may have 10 (client side) invalid fields, but Form's props.errors would be empty.
We propose removing validations entirely, requiring consumers of Frig to implement their own custom validation in the onChange and onSubmit handlers.
Pros:
- Clearer, more explicit, less magic
- Full control, e.g. users would be able to control whether the form validates on change, on submit, or both
- Field-level errors could be cascaded up to the
<FormErrorList/>
Cons:
- More boilerplate
- Loss of declarative validations, e.g.
<Input type="number" min="10" max="20" />
We would like to remove validations from Frig.
There are two types of errors/validations in Frig:
<Form errors={}>attribute, typically server-side errors (but could be anything)As for "Frig validations", users don't have a lot of control over these. We provide three very basic validations,
required,min, andmax. There is no support for custom validations."Frig validations" run in a way that is inconsistent with the
<Form errors={}>attribute.When a field changes, we run these validations. If there is an error, we display the error message next to the field.
<Submit>will simply refuse to call Form'sonSubmitif there are any errors.There is no way to programatically access or manipulate these field-level, client-side errors. They also don't cascade up to the
<FormErrorList>object. A form may have 10 (client side) invalid fields, butForm'sprops.errorswould be empty.We propose removing validations entirely, requiring consumers of Frig to implement their own custom validation in the
onChangeandonSubmithandlers.Pros:
<FormErrorList/>Cons:
<Input type="number" min="10" max="20" />