According to https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback we can pass options.language to validate to override languages
I have a multi-language application , I successfully override Joi core languages such as object.max
But I cannot override extension languages
const BaseJoi = require('joi');
const JoiPhoneNumberExtensions = require('joi-phone-number-extensions');
const Joi = BaseJoi.extend(JoiPhoneNumberExtensions);
const schema = Joi.phoneNumber().defaultRegion('US').type('MOBILE').format('E164');
BaseJoi.validate(
'invalid phone',
schema,
{
language:{
phoneNumber : {
base: 'base overrided',
region: 'region overrided',
emptyFieldRef: 'emptyFieldRef overrided',
illegalRefRegion: 'illegalRefRegion overrided',
type: 'type overrided',
format: 'format overrided',
}
},
},
(err, value) => {
console.log(err)
}
);
@Marsup can you please reply?
I recognize this is a bug, extensions are considering language as local options (which always override global options) which prevents language overriding. I'm not sure I'll be able to fix it quickly so unless you can maybe you'll have better luck post-processing the errors from the details array which is I think a better way of doing i18n, there are npm modules doing it for you I think.
@Marsup can you tell me , when you can fix it?
@Marsup reply please
Not the best way to get a response, honestly. I can assure you he has not forgotten this, and does keep up with issues and bugs; so if you haven't gotten a response in 2 days it's probably because he is busy with his full-time job (which is not Joi maintenance).
@WesTyler OK , sorry
Even though this is technically a breaking change, I'm going to put it out there as a patch because it was a misguided implementation.
@Marsup When you release 15.0.1?
It is now.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.