joi icon indicating copy to clipboard operation
joi copied to clipboard

order of methods throws exception

Open yovasx2 opened this issue 2 years ago • 0 comments

node 16.16 joi 17.6.1

Joi.object({password: Joi.string().min(6).required().message('Password is required!')}); Uncaught: Error: Cannot apply rules to empty ruleset or the last rule added does not support rule properties at new module.exports (/Users/yovasx2/idpartner/node_modules/@hapi/hoek/lib/error.js:23:19) at module.exports (/Users/yovasx2/idpartner/node_modules/@hapi/hoek/lib/assert.js:21:11) at internals.Base.rule (/Users/yovasx2/idpartner/node_modules/joi/lib/base.js:479:9) at internals.Base.method [as message] (/Users/yovasx2/idpartner/node_modules/joi/lib/extend.js:145:29)

but inverting min and required works

Joi.object({password: Joi.string().required().min(6).message('Password is required!')});

it works

yovasx2 avatar Oct 26 '22 21:10 yovasx2