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

Cannot return object using yup setLocale #4913

Open
5 tasks done
murshex opened this issue Oct 25, 2024 · 1 comment
Open
5 tasks done

Cannot return object using yup setLocale #4913

murshex opened this issue Oct 25, 2024 · 1 comment
Labels
👕 TypeScript TypeScript typings issue

Comments

@murshex
Copy link

murshex commented Oct 25, 2024

What happened?

I can't return an object using yup setLocale.

For example: (From yup docs)

yup.setLocale({
  number: {
    min: ({ min }) => ({ key: 'field_too_short', values: { min } }),
  },
});

// Errors are typed as string, but yup will return an object!
const { errors } = useForm();

Reproduction steps

...

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

No response

Demo link

in progress

Code of Conduct

@logaretm logaretm added the 👕 TypeScript TypeScript typings issue label Oct 26, 2024
@logaretm
Copy link
Owner

logaretm commented Oct 26, 2024

This was reported before in #3361, I closed it due to no activity or new requests.

Main issue is there is no way to connect yup.setLocale calls with dynamic types that would change errors or errorMessage types from strings to objects as this is all statically typed.

One good suggestion was in #4044 but I would need to build a new API for that.

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

No branches or pull requests

2 participants