Skip to content
Advertisement

Tag: joi

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

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

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

Advertisement