-
Notifications
You must be signed in to change notification settings - Fork 928
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
Support custom locale #105
Conversation
Supports now the user passing her own locale which will get deep merged and the missing fields will default to the current one
src/locale.js
Outdated
@@ -1,13 +1,19 @@ | |||
import { merge } from 'lodash/fp' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use Object.assign
instead of a lodash module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went for lodash.merge because it'll merge deeply, so the user can change just one entry and let the rest default for the current ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you aren't doing any deep merging though, since it's merging each namespace individually. I'd prefer to maintain that as well since merge
is not the tiniest part of lodash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now I got what you meant haha
I'm going to make the adjustments soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
Thanks for taking the time to do this 👍 |
Done @jquense |
In need of this. |
README.md
Outdated
@@ -138,6 +139,19 @@ schema.cast({ | |||
// => { name: 'jimmy', age: 24, createdOn: Date } | |||
``` | |||
|
|||
### Using a custom locale dictionary | |||
```js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you flesh this out a bit more, explanation of the code, why you need to do this, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I'll do it soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done @jquense
👍 |
README.md
Outdated
|
||
// Now use Yup schemas AFTER you defined your custom dicionary | ||
``` | ||
Why do you have to set the locales before you use Yup at all? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was think more about what this does generally, not why it needs be first. something like:
"Allows you to customize the default messages used by Yup, when no message is provided with a validation test."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh ok
thanks! |
Support custom locale
In order to work now, the user should create a file like this and initialize it before all yup usage.
I'm going to add tests and update README after you guys approve this!
Thanks for the great package btw. Let me know if any changes are necessary before merging.