Skip to content

Remove validations from Frig #103

@jbinto

Description

@jbinto

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" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions