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(),   }...
Is it possible to validate that a boolean is true using Joi? I've tried using allow, valid and invalid without any luck....
I have an API which has to validate OpenApi specifications. I get the payload in OpenApi format like below:  {     "swagger": "2.0",     "info": {         "description": "This is a sample server Petstore server. Yo...
I am working on an api that should allow multiple params but for three of them I would like to allow only one of them. It easier with values for each key but I am wondering if Joi allows it too or I should add extra validation logic in my server.   I...
I try to validate the query parameter userId.  If a user is an admin then he can use any user id.  If no - then use the only id from a specific array.  const validUserIds = isUserAdmin ? req.query.userId : userIds; const schema = Joi.object().keys({...
My goal is to allow a nested object of an arbitrary depth that can contain anything. Within that nested object I want to perform extra validation only on strings.   So, the object could look like this:  {   "features": {     "feature1"...
I have this json:  let purchaseSubscription = {   'metadata': {     'eventName': 'PurchaseSubscription',     'type': 'setup' // setup, repurchase or recurring   },   'data': {     'subscriptionId...
Struggling to find anything about this in the docs - is it possible to reference multiple values?  Say I have a schema that takes 3 numbers (a, b, c), is it possible to set a max property on c based on a and b. Something like the following:  joi.obje...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.