If I have two fields, I'd just like to validate when at least one field is a non empty string, but fail when both fields are empty strings. Something like this does not validate var schema = Joi.object().keys({ a: Joi.string(), b: Joi.s...
This question already has an answer here:...
Simple joi validation snippet in javascript.It will simply return an error object when validation fails. validate.js const Joi =require("joi"); function validateObject (input) { const schema = { key: Joi.string().required(), }...
I am trying to create nested schema in joi and it is throwing error [Error: Object schema cannot be a joi schema] var nestedSchema = joi.object({ b: joi.number() }); var base = joi.object({ a: joi.string(), nestedData:joi.object(nest...
I want to validate my Express routes before calling the controller logic. I use joi and created a validator which is able to validate the Request object against the schema object import { Request, Response, NextFunction } from 'express'; imp...
I have the following validation on one of my routes: payload: { keywordGroups: Joi.array().items(Joi.object().keys({ language: Joi.string().required(), containsAny: Joi.array().items(Joi.string()).default([]).when('containsAl...
I search a lot but nothing found to allow multiple type validation in Joi Link: https://github.com/hapijs/joi I would like to use something like this: validate: { type: joi.or([ joi.string(), joi.array(), ]) };...
Is it possible to validate that a boolean is true using Joi? I've tried using allow, valid and invalid without any luck....
I'm using node module Joi to make some validations and I am having trouble using the .or() method. In their documentation they specify the use as: var schema = Joi.object().keys({ a: Joi.any(), b: Joi.any() }).or('a', 'b'...
I'm looking for a way to validate that an array contains a required value using joi. Found these issues online - #1, #2, but none of them has a definitive answer. I tried several stuff but they doesn't seem to work, like: joi.array().items(jo...
©2020 All rights reserved.