You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What are you trying to achieve or the steps to reproduce ?
I have tried to add new rule for object but after it many validations become broken.
Example of code to reproduce is below.
constJoi=require('joi');constschema=Joi.object({position: Joi.object({x: Joi.number(),y: Joi.number()}).required()});constdata={position: JSON.stringify({x: 100,y: 200})};console.log(Joi.validate(data,schema));/*There I got result as expected. There will be error if data.position.x = 'hello'*//*{ error: null, value: { position: { x: 100, y: 200 }}, then: [Function: then], catch: [Function: catch] } */
constorigJoi=require('joi');constJoi=origJoi.extend((joi)=>{return{name: 'object',base: joi.object(),rules: [{name: 'newRule',validate(params,value,state,options){returnvalue;}}]};});constschema=Joi.object({position: Joi.object({x: Joi.number(),y: Joi.number()}).required()});constdata={position: JSON.stringify({x: 'hello',y: 200})};console.log(Joi.validate(data,schema));/*There is unexpected result. There is no error on data.position.x and data.position is not parsed*//*{ error: null, value: { position: '{"x":"hello","y":200}' }, then: [Function: then], catch: [Function: catch] } */
The text was updated successfully, but these errors were encountered:
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.
lockbot
locked as resolved and limited conversation to collaborators
Jan 9, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Context
What are you trying to achieve or the steps to reproduce ?
I have tried to add new rule for object but after it many validations become broken.
Example of code to reproduce is below.
The text was updated successfully, but these errors were encountered: