Add validation functions for textArea and dropdown#82
Conversation
| , _validationConfig_initialAttributes = mempty | ||
| , _validationConfig_validAttributes = mempty | ||
| , _validationConfig_invalidAttributes = mempty | ||
| , _validationConfig_initialValue = "" |
There was a problem hiding this comment.
Maybe require Monoid v here and add a second mkBaseValidationConfig or something without that constraint that takes an argument.
There was a problem hiding this comment.
Okay. Does it make sense to deprecate defValidationConfig in the process? Because I wonder about the value of having two functions (with non-similar names to boot).
There was a problem hiding this comment.
mkValidationConfig seems like a better name since "base" is not in the type's name. You can't deprecate the argument-taking one because v may not be monoidal. (Unless you expect people to construct from the record directly...)
There was a problem hiding this comment.
You can't deprecate the argument-taking one
Yea, but I meant: deprecate the other one (one that has the Monoid constraint).
There was a problem hiding this comment.
Isn't that the one that @eskimor is proposing you add? Maybe I missed something.
There was a problem hiding this comment.
I think not having to provide an argument for the common case is useful and would make this change less breaking (maybe not breaking at all). So I don't think we need to deprecate anything.
| { _validationDropdown_input :: Dropdown t (Maybe a) | ||
| , _validationDropdown_value :: DynValidation t e a | ||
| } | ||
|
|
There was a problem hiding this comment.
Why do we need validation for a dropdown? Shouldn't we just only offer options that are valid?
There was a problem hiding this comment.
@eskimor One of the items in the dropbox can be "Select an item" (which would be the default selection). If the user has not in fact selected one of the other items, we would want to display a validation error.
The "Select an item" thing would be Nothing, and the other items Just a. So we would just use the validateJust function here.
a5c5482 to
c82d0e6
Compare
(cherry picked from commit a5c5482)
c82d0e6 to
5b334cd
Compare
|
This PR now targets the |
To compensate for the fact that Dropdown has no HasDomEvent instance (cherry picked from commit fbe9e2b)
The current
validationInputonly works withinputElement. This PR creates two similar functions to work withtextAreaanddropdown.Unlike the other two input types, dropdown input's values can be of arbitrary type,
v, instead of necessarily beingText. To accommodate thisValidationConfigtype now takes an extra type parameter,v, that specifies this type. ForvalidationInputandvalidationTextAreathis isText, but forvalidationDropdownit is the user that will provide this type.