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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -