You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case we have form fields that have custom options that might conflict with each other (for instance, "minimum length" and "maximum length", where min > max), we should be able to generate an error when constructing a field, rather than in clean_value, for instance.
Technically, this is now possible by overriding FormField::with_options and just panicking there. Right now, we implement this trait with a macro (impl_form_field), so there are multiple options to solve the problem:
Change the macro so that some additional code can be added to the FormField::with_options implementation
Change the FormField::CustomOptions type to enforce validation before constructing an instance of CustomOptions somehow (this approach is slightly more complicated, because this would require some changes in the derive macro implementations, but is arguably more "correct")
@m4tx I moved the validation to the Field creation by introducing a ValidateOptions trait, which should be called before the field is created here #304 . What are your initial thoughts about this approach?
In case we have form fields that have custom options that might conflict with each other (for instance, "minimum length" and "maximum length", where min > max), we should be able to generate an error when constructing a field, rather than in
clean_value
, for instance.Technically, this is now possible by overriding
FormField::with_options
and just panicking there. Right now, we implement this trait with a macro (impl_form_field
), so there are multiple options to solve the problem:FormField::with_options
implementationFormField::CustomOptions
type to enforce validation before constructing an instance ofCustomOptions
somehow (this approach is slightly more complicated, because this would require some changes in the derive macro implementations, but is arguably more "correct")Context: #286 (comment)
The text was updated successfully, but these errors were encountered: