react-hook-form-mui
react-hook-form-mui copied to clipboard
DatePicker/DateTimePicker/TimePicker clobber validate function
Duplicates
- [X] I have searched the existing issues
Latest version
- [X] I have tested the latest version
Current behavior 😯
react-hook-forms allows you to pass either an object or a function as the validate
param, e.g.
rules={{
validate: (x) =>Number.isInteger(x)
}}
but react-hook-form-mui seems to expect only an object
You can work around this by nesting the rule:
rules={{
validate: {
workaround: (x) =>Number.isInteger(x)
}
}}
but ideally that wouldn't be necessary.
Expected behavior 🤔
Passing a validate
function in rules should just work, ideally. That might require reworking rulesTmp, however. One option might be to have rulesTmp put the user's validate function in a subproperty of validate, although it would mess with looking up errors manually from the errors object.
This might be OK if appropriately documented.
Steps to reproduce 🕹
Steps: