Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View 'global' error on validationSchema's yup object #168

Open
dev-Luka opened this issue May 27, 2022 · 0 comments
Open

View 'global' error on validationSchema's yup object #168

dev-Luka opened this issue May 27, 2022 · 0 comments

Comments

@dev-Luka
Copy link

dev-Luka commented May 27, 2022

Good afternoon

I guess this is more of a question. How would you correctly access an error message that has been set on the 'top-level' yup object, you set validationSchema to?

Let's say you write the following schema:
yup.object().shape({
finished: yup.array().of(yup.string()),
personal_remarks: yup.string(),
person_name: yup.string()
}).test('at least one field', 'Cannot submit empty', (value) => {
return !!(value.finished.length || value.personal_remarks)
});

The focus is on the last 'test' function on the yup object. When you set validationSchema in createForm function to the above schema, it seems to work: svelte-forms-lib prevents you from submitting. But: the error message is put in $errors.undefined, which seems odd...

Is this because $errors should only contain errors from the values in 'initialValues'? Or how would you solve this issue in svelte-forms-lib?

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant