-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codebugBug or defectBug or defect
Milestone
Description
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)
}
);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codebugBug or defectBug or defect