I seem to hit a roadblock when it comes to joi’s .or() function as it doesn’t seem to implement as I’d expect. I have 2 text input fields, both have their own way of validating, though only at least one is required. it just seems that this or doesn’t do as I’d expect and each field from the or is
Tag: joi
Node js Joi validation to send error if string contains space at start or end
How to create JOI validation with Node js if string contains empty space at start or end send error example : if input is name = “test123” //valid name = “test(space)” or “(space)test” // invalid Answer You can use below regex to validate the your cases
JOI validation for a string with json as a value
i am trying to validate the string using the JOI package available in npm, i checked this documentation which has many useful string formats e.g. date, IP, base64 but i need to validate the following JSON which contains a stringified JSON as a value, and there is no example in the documentation for such case So for example what if
Nested object in Joi schema
I’ve defined validation schema via Joi with nested object in AWS value: Then I put my schema to config module I’ve added inside .env file the next value for AWS variable: but I got the next error message after starting nest: typeof process.env.AWS returns a string and Joi doesn’t understand that he should parse it, maybe I need to add
Is it necessary to use multiple Joi schema validations with Hapi?
I looked at an existing codebase and and I noticed that the codebase had two schema validations for what I feel a single schema could validate as the second schema is an offshoot of the first. See codebase below. Now these schema are being used in the following routes: I am new to Hapi but have some experience with Express
How to Joi-Allow an empty Date String [Joi]
as the title states, how to allow an empty Date-String through Joi validation. When adding: it gets the Issue: message: “”Date” must be a number of milliseconds or valid date string” with this Joi-Validation: Question: How can an empty Date-String be allowed through Joi validation? EDIT: By removing: .required() and or adding .default(“”) i do get another error, when adding
TypeError Joi.validate is not a function
please help with that i am not sure what is happening im using the following: but it is only the joi that im having issues with Answer Try schema.validate instead of Joi.validate Reference: https://joi.dev/api#example
how to give interface for joi-objectid?
I am using joi to validate the schema of my objects. For objectid validation joi has a seperate package joi-objectid. I am using it for objectid validation. But recently when i am trying to migrate my code into typescript joi is throwing an error that objectid does not exist on joi. Since it is added at runtime we cannot get
Joi Nested schema
I am trying to create nested schema in joi and it is throwing error [Error: Object schema cannot be a joi schema] How should i define nested schema in joi? Answer You could use object.keys API