Duplicates
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:
Duplicates
Latest version
Current behavior 😯
react-hook-forms allows you to pass either an object or a function as the
validateparam, e.g.but react-hook-form-mui seems to expect only an object
You can work around this by nesting the rule:
but ideally that wouldn't be necessary.
Expected behavior 🤔
Passing a
validatefunction 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: