Love this library. I currently have custom extensions that I use to extend the joi library. However, as soon as I use the Joi.extend function to add custom joi types then joi-extract-types no longer works.
const numberExtensions = (joi : any) : Extension => ({
base: joi.number(),
name: 'number',
language: {
cLatitude: 'needs to be a valid latitude',
cLongitude: 'need to be valid longitude'
},
rules: [
{
name: 'cLatitude',
validate(params, value, state, options) {
if (value >= -90 && value <= 90) {
return value;
}
// Generate an error, state and options need to be passed
return this.createError('number.cLatitude', {value}, state, options);
}
},
{
name: 'cLongitude',
validate(params, value, state, options) {
if (value >= -180 && value <= 180) {
return value;
}
// Generate an error, state and options need to be passed
return this.createError('number.cLongitude', {value}, state, options);
}
}
]
});
module.exports = joi => (joi.extend(numberExtensions));
If I extend Joi to use the above extension then all types become any. Please let me know if there is a workaround for this. Thanks!
Love this library. I currently have custom extensions that I use to extend the joi library. However, as soon as I use the Joi.extend function to add custom joi types then joi-extract-types no longer works.
If I extend Joi to use the above extension then all types become any. Please let me know if there is a workaround for this. Thanks!