Node.js + Joi how to display a custom error messages?

Original answer: The current way (I personally find it better) is to use .messages() (or .prefs({messages})). const Joi = require(‘@hapi/joi’); const joiSchema = Joi.object({ a: Joi.string() .min(2) .max(10) .required() .messages({ ‘string.base’: `”a” should be a type of ‘text’`, ‘string.empty’: `”a” cannot be an empty field`, ‘string.min’: `”a” should have a minimum length of {#limit}`, ‘any.required’: … Read more

Joi validation of array

Joi.array().items() accepts another Joi schema to use against the array elements. So an array of strings is this easy: Joi.array().items(Joi.string()) Same for an array of objects; just pass an object schema to items(): Joi.array().items(Joi.object({ // Object schema }))

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)