-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove validations from Frig #103
Comments
Not necessary because the validation could still happen, on the theme side, where all of the components could have individual validation. For example, the Number component could have a min and max validation, on its value, then display an error using the themes error list component. |
Some early (non-binding!) thoughts on how this could work: Option 1:
Option 2:
More ideas re: option 2:
{
presence: (v) => v != null,
min: (v, min) => v > min,
max: (v, max) => v < max,
fizzbuzz: (v) => v % 5 == 0 && v % 3 == 0,
} Potential challenges:
|
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'sonSubmit
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, butForm
'sprops.errors
would be empty.We propose removing validations entirely, requiring consumers of Frig to implement their own custom validation in the
onChange
andonSubmit
handlers.Pros:
<FormErrorList/>
Cons:
<Input type="number" min="10" max="20" />
The text was updated successfully, but these errors were encountered: