Top "Joi" questions

Object schema description language and validator for JavaScript objects.

Joi validation - how to require or optional field based on another key exists in array?

I have this Joi schema: let schema = {}; let stations = { contact: { first_name: Joi.string().min(2).max(10).regex(Regex.alphabeta, 'alphabeta').…

node.js validation schema joi
Using Joi, require one of two fields to be non empty

If I have two fields, I'd just like to validate when at least one field is a non empty string, …

javascript hapijs joi
Joi object validation: How to validate values with unknown key names?

I have an object with key names I cannot possibly know - they are created by user. However I do …

validation hapijs joi
Joi Validation - Compare to dates from POST

I'm currently using Joi in HapiJS / NodeJS to validate data. One POST in particular has two ISO dates (start date …

node.js validation hapijs joi
How to add custom validator function in Joi?

I have Joi schema and want to add a custom validator for validating data which isn't possible with default Joi …

javascript node.js validation express joi
How to set custom error messages in @hapi/joi?

I've created following Schema for validation using Joi: const createProfileSchema = Joi.object().keys({ username: Joi.string() .required() .message("username is …

node.js validation express joi
Using Joi, validating that a boolean is true

Is it possible to validate that a boolean is true using Joi? I've tried using allow, valid and invalid without …

javascript hapijs joi
Nodejs - Joi Check if string is in a given list

I'm using Joi package for server side Validation. I want to check if a given string is in a given …

node.js joi
JOI :allow null values in array

I am trying to add a validation for array in a POST request Joi.array().items(Joi.string()).single().optional() …

javascript node.js hapijs joi
How to format JOI date/schema correctly?

I've got a function which enforces validation restrictions via obj.pattern. The key which I would like to validate is …

javascript joi