node.js - Joi.array().includes is not a function error -
i validating payload data of api joi validation. have made 1 schema this:
'use strict'; let mongoose = require('mongoose'); let schema = mongoose.schema; let tokenschema = new schema({ level : {type : number}, tokenvalues : [{ level : {type : number}, amount : {type : number} }] }); module.exports = mongoose.model('tokens',tokenschema,'tokens');
i have written joi validation:
validate: { payload: { level: joi.number().required(), tokensvalues: joi.array().includes({ level : joi.number().required(), amount : joi.number().required() }) } }
this above code giving error :
typeerror: joi.array(...).includes not function
please suggest other method if wrong practice.
i got solution :
validate: { payload: { level: joi.number().required(), tokensvalues: joi.array().items(joi.object().keys({ level : joi.number().required(), amount : joi.number().required() })) } }
Comments
Post a Comment