arfurlaneto/yup-locale-pt

Singular and plural nouns in error messages

Closed this issue · 1 comments

Parameters are being referred to in the plural form, even when they are singular.
For example, this error message for array().min(1):

Deve ter pelo menos 1 itens.
                      ^^^^^

Taking a look at the yup documentation, I think we can fix it by passing a function like this:

min: ({ min }) => `Deve ter pelo menos ${min} ${min == 1 ? 'item' : 'itens'}.`

We will have the same problem with string().length(), string().min() and string().max() validators.
Thanks for the tip, the fix looks good!
I'll add some new tests to cover this case and fix it in the next days =)