question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

does this library has support for custom setLocaly in yup

See original GitHub issue

I tried to defined a custom setlocale for custom error messages, but always get the default ones defined in yup, I defined something like this, before my validation schema:

setLocale({
    string: {
      required: 'Requerido',
    },
  })

//schema

validationSchema: yup.object().shape({
      password: yup.string().required(),
    }),

The idea is define a global config error message to avoid doing the same in each validationschema like the example file:

validationSchema: Yup.object().shape({
    email: Yup.string()
      .email('Invalid email address')
      .required('Email is required!'),
  }),

Thank you this is an awesome Lib

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
dccarmocommented, Feb 7, 2018

Just a heads up to @yanv1991, your code wasn’t working because there isn’t a required locale for string.

You have to use mixed:

  setLocale({
    mixed: {
      required: 'Requerido',
    },
  })
0reactions
jquensecommented, Oct 12, 2017

with v0.23 (along with sync validation!) setting the locale is not import order dependent so should be a problem any more 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Yup - npm
Using a custom locale dictionary. Allows you to customize the default messages used by Yup, when no message is provided with a validation...
Read more >
yup - npm.io
Yup is a JavaScript schema builder for value parsing and validation. ... If you need multi-language support, Yup has got you covered. The...
Read more >
schema-to-yup - npm Package Health Analysis - Snyk
Build a Yup schema object to validate models from a domain model schema (JSON or ... This library is built to be easy...
Read more >
How to customize yup validation messages? - Stack Overflow
You could do it by using setLocale function from yup like this: ... The section Using a custom locale dictionary is what you...
Read more >
Dependency injection in action - Angular
A good example is a service that holds state for its companion component ... Angular starts with that component's injector and walks up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found