joi icon indicating copy to clipboard operation
joi copied to clipboard

Empty string not allowed?

Open besarthoxhaj opened this issue 11 years ago • 3 comments

I have a form which the user can fill or not leaving empty field. Is there are way to make this pass:

var Joi = require('joi');

var test = Joi.string();

Joi.validate('', test, function (err, value) {

  // this does error here
});

Thank you!

@benjaminlees @NataliaLKB

besarthoxhaj avatar Jul 20 '15 22:07 besarthoxhaj

You might try Joi.string().empty('');

nlindley avatar Jul 20 '15 22:07 nlindley

2nd sentence of the string documentation.

Marsup avatar Jul 20 '15 22:07 Marsup

Coding for too long! Should have noticed that! Thanks guys!

besarthoxhaj avatar Jul 20 '15 22:07 besarthoxhaj