hapijs / joi

The most powerful data validation library for JS
Other
20.88k stars 1.51k forks source link

Validation message in Arabic language #2941

Open MGenidyO opened 1 year ago

MGenidyO commented 1 year ago

Support plan

Context

What problem are you trying to solve?

image

 const ngoNameArSchema = joi.string()
            .pattern(new RegExp('^[\u0621-\u064A\u0660-\u0669\0-9]+$'))
            .min(2)
            .max(30)
            .messages({
                //'string.base': `required`,
                //'string.empty': `cannot be an empty field`,
                'string.min': '@T["validation-message-minimum-string"]',
                'string.pattern.base': `allow only arabic characters`,
                //'any.required': `is a required field`
            });

Do you have a new or modified API suggestion to solve the problem?

sorry for now no

Marsup commented 1 year ago

It looks like an HTML entity escaping issue, I'm uncertain if it's joi's fault. Can you provide a reproducible snippet that demonstrates the issue?

MGenidyO commented 1 year ago

i fixed it by ternary operator and writing the Arabic message in js directly but to me it will be better if i will able to display the message via localization

image

Marsup commented 1 year ago

You can also keep the same schema and use multiple languages, like in this example.