joi Questions

3

I have a field in a JOI schema that I would like to be optional (i.e. undefined is accepted, and null is also accepted), however if a value for it is supplied, it must be a positive integer. How mi...
Trangtranquada asked 9/9, 2021 at 4:9

4

Solved

I have Joi schema and want to add a custom validator for validating data which isn't possible with default Joi validators. Currently, I'm using the version 16.1.7 of Joi const method = (value, help...
Criseyde asked 17/10, 2019 at 5:30

3

Solved

I have the following schema: var testSchema = Joi.object().keys({ a: Joi.string(), b: Joi.string(), c: Joi.string().when('a', {'is': 'avalue', then: Joi.string().required()}) }); but I woul...
Trimetallic asked 22/10, 2014 at 14:13

4

Solved

I'm using Joi package for server side Validation. I want to check if a given string is in a given list or if it is not in a given list.(define black list or white list for values) sth like an &quot...
Burglarize asked 31/12, 2016 at 12:55

3

Solved

I have a joi schema called user const user = { firstName: Joi.string() .min(2) .max(50) .required() .label('First Name'), lastName: Joi.string() .min(3) .max(50) .required() .label('Last...
Anastasius asked 29/7, 2019 at 7:11

2

Solved

I've got a function which enforces validation restrictions via obj.pattern. The key which I would like to validate is a formatted date which is provided to the function in the following format DD/...
Holusbolus asked 4/9, 2019 at 16:27

3

Solved

I've created following Schema for validation using Joi: const createProfileSchema = Joi.object().keys({ username: Joi.string() .required() .message("username is required") .empty() .message("...
Hilel asked 16/10, 2019 at 7:53

2

I'm looking into using Joi for api validation. I can't seem to confirm whether my schema is correct in that I want either the email or mobile to be required (but they both can't be empty/non exist...
Syphilology asked 18/2, 2016 at 18:33

2

Solved

I have implemented this code using JOI where the user has to send the userId and at least one of the keys from the body. How to implement the same using ZOD ?? params: Joi.object().keys({ userId:...
Skurnik asked 8/8, 2022 at 16:55

6

Solved

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....
Frigorific asked 4/3, 2015 at 20:59

3

Solved

I want to implement frontend validation with either Yup or Joi. From all the docs and articles that I've found, I've got to a couple of conclusions: Joi has better performance Joi is more po...
Eatables asked 2/2, 2021 at 12:15

8

Solved

Using Joi schema validation, is it possible to validate against MongoDB ObjectID's? Something like this could be great: _id: Joi.ObjectId().required().error(errorParser),
Reprography asked 26/8, 2019 at 13:27

7

Solved

I need to create dynamic schema to validate my api request query in node js using Joi validator depending on a key in the request query. Say the following below mentioned pattern are my valid queri...
Pulmotor asked 22/1, 2020 at 14:5

2

I am using @hapi/joi for express validation and sanitation. When validating, certain validators are not working. In this one, not only does trim() not validate for white space at the beginning and ...
Couperin asked 4/4, 2020 at 1:10

2

I read Node.js + Joi how to display a custom error messages? and am still having trouble. I have a schema like this: const create = validator.object().keys({ app: validator .string() .required()...
Meridethmeridian asked 5/2, 2021 at 20:57

1

Solved

I am having an array of objects to validate from the specific schemas and if any of the objects matches with the given schemas, I want to validate against it and ignore other schemas and move to ne...
Pournaras asked 2/12, 2022 at 16:45

5

Solved

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 sc...
Abaddon asked 16/10, 2019 at 9:33

6

I am getting an array of objects to backend, where each object contains a service name. The structure looks like below [{"serviceName":"service1"}, {"serviceName":"service2"},..] when I get the...
Bentinck asked 10/6, 2016 at 9:18

5

Solved

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...
Lannylanolin asked 20/4, 2016 at 9:27

2

When using Joi.array().items(...) does this require that at least one item be present, even if no type matchers are marked as required?
joi
Apiculate asked 9/9, 2021 at 21:40

9

i want that if the number of digits in the input field in less/more than 14(for example) then joi should return an error. how can i do this with the type of number not for string.
Twine asked 18/9, 2019 at 12:53

0

Let there be: const a = { b: Joi.alternatives().conditional("a", { is: "c", then: Joi.any(), otherwise: Joi.string().valid("d", "e").required(), }), a:...
joi
Grande asked 9/10, 2022 at 12:50

1

Straight from the docs, alternatives.conditional: Adds a conditional alternative schema type, either based on another key value, or a schema peeking into the current value any.when: Adds conditi...
Mccollough asked 9/10, 2022 at 10:3

1

Solved

After installing joi on nestjs framework i'm trying to validate two property by joi something like: import Joi from 'joi'; ... ConfigModule.forRoot({ isGlobal: true, validationSchema: Joi.object(...
Bowser asked 28/7, 2022 at 13:1

1

Solved

My schema is: const scenerioSchema = Joi.object({ drawingNode: Joi.object({ moduleRackOutputs: Joi.array() .items( Joi.object({ moduleId: Joi.string().required() }) ) .unique((a, b) => a...
Kierkegaardian asked 11/1, 2022 at 16:23

© 2022 - 2024 — McMap. All rights reserved.