-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing coderelease notesMajor release documentationMajor release documentation
Milestone
Description
Summary
Joi 5.0.0 changes a few default behaviors that were surprising to a few users.
- Upgrade time: low to none - most people shouldn't have to do anything
- Complexity: low - the new defaults will probably already be what you want, otherwise it will be just a function call
- Risk: low - if you don't fall into the following edge cases, it should be a very low risk upgrade
Breaking changes
number()rejectsInfinityand-Infinityby default. If you do wantInfinityto be accepted as a number, you have to usenumber().allow(Infinity, -Infinity)array()rejects sparse arrays by default (arrays with undefined values), this can still be enabled by callingarray().sparse().array().unique()will now perform a deep comparison where necessary, previous implementation only compared numbers and strings. Be aware that doing so will indeed have a cost in performance.number().precision()will convert numbers to the given precision ifconvert: true.
New features
array().single()whenconvert: truewill try to wrap your value inside an array if it doesn't validate as it is, especially useful when you want to accept a type or an array of that type.- the context will now be returned in the errors allowing you have a better insight into the parameters of the rule that triggered the error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing coderelease notesMajor release documentationMajor release documentation