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
The validateSync() function may return invalid error paths for some nested object field names containing "." (period).
Namely, the invalid paths returned are missing quotes.
To Reproduce
Given the following schema and object...
const schema = yup.object({
"i.t._admin_name": yup.string().required("Enter a valid name"),
"i.t._admin_email": yup
.string()
.required("Enter a valid email")
.test("valid_email", "Email is invalid", (val) => {
return false; // This test always fails to simplify the demonstration
}),
});
// This example demonstrates the bug - we expect errors for both keys.
const obj = {
"i.t._admin_name": "",
"i.t._admin_email": "invalid email",
};
Evaluating schema.validateSync(obj, { abortEarly: false }) throws a validationError containing the following paths:
Describe the bug
The
validateSync()
function may return invalid error paths for some nested object field names containing "." (period).Namely, the invalid paths returned are missing quotes.
To Reproduce
Given the following schema and object...
Evaluating
schema.validateSync(obj, { abortEarly: false })
throws a validationError containing the following paths:["i.t._admin_name"]
[i.t._admin_email]
This test case is demonstrated here: https://codesandbox.io/p/devbox/yh65qd
Expected behavior
We'd expect the paths to be:
["i.t._admin_name"]
["i.t._admin_email"]
Platform
All tested browsers, versions including Chrome, Firefox.
Additional context
Bug discovered while integrating Yup with Formik and React.
The text was updated successfully, but these errors were encountered: