-
-
Notifications
You must be signed in to change notification settings - Fork 200
Closed
Description
Describe the bug
Code breaks when adding custom validation logic via addMethod function.
Code returns :
vendors-node_modules_apollo_client_index_js-node_modules_hookform_resolvers_yup_dist_yup_modu-7f163c.js:9521 Uncaught (in promise) TypeError: Cannot read property 'reduce' of undefined message.
To Reproduce
Just add custom validation to yup
yup.addMethod(yup.object, 'localeEqual', function (errorMessage) {
return this.test('locale-equal', errorMessage, function (value) {
const {path, createError} = this
return value.kz.length === value.ru.length || createError({path, message: errorMessage})
})
})
CodeSandbox
https://codesandbox.io/s/yup-custom-validation-error-41x1n?file=/src/App.js
Metadata
Metadata
Assignees
Labels
No labels