order of methods throws exception
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
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
Contributor guide
Research direction
Reproduce the two Joi 17.6.1 examples first, then inspect joi/lib/base.js and joi/lib/extend.js at the stack-trace locations for rule and method ordering. Done means the min().required().message() order no longer throws while preserving the working order, with regression coverage for both examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100