Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14.0.0 Release Notes #1615

Closed
Marsup opened this issue Oct 14, 2018 · 1 comment
Closed

14.0.0 Release Notes #1615

Marsup opened this issue Oct 14, 2018 · 1 comment
Assignees
Labels
breaking changes Change that can breaking existing code release notes Major release documentation
Milestone

Comments

@Marsup
Copy link
Collaborator

Marsup commented Oct 14, 2018

Summary

This major version introduces a lot of breaking changes, trying to fix some long lasting quirks. Most of the breaking changes should be edge cases but I encourage you to read those notes carefully as you may be exposed.

  • Upgrade time: medium to high
  • Complexity: low
  • Risk: high

👥 Contributors

The code contributors to this release are : @BolajiOlajide and myself.

Special thanks to @nearform who sponsored most of my time on this release!

⚠️ Breaking changes

stripUnknown: true defaults to not strip array items (#1614)

This flag now gets what everyone seems to expect, that is strip object keys, but not invalid array items. I guess you can all go back to stripUnknown: true.

Stricter and safer parsing of numbers (#1113, #1504, #1544)

From now on, numbers are checked to be within range of what JavaScript considers safe (see Number.isSafeInteger). You can disable this behavior by doing Joi.number().unsafe() but I would personally advice against that.

Also, numbers, when converted from strings, will check for conversion fidelity, meaning there will be errors if you lost some precision on the way.

And finally, numbers written in another base (0xA, 0o7, ...) were improperly converted, they will be denied from now on. An option to support that in the future could be added but there hasn't been much demand.

Fixed output result of Joi.string().valid(...).insensitive() (#1191)

valid is used to provide a white-list of values, and insensitive could influence how strings are matched inside that list, but the previous behavior was only to check whether it matched, and then return the input. This is wrong because what you most likely expect is to get a string that is inside that white-list, not some upper-cased version of it. This is now fixed and you'll get exactly what you white-listed.

Nested paths on object.or/nand/and/xor/with/without() (#1477, #1554)

Nested paths on those functions are now supported. I consider this a breaking change as you may (but you really really shouldn't) have used dotted paths in those validations because you wanted to check dotted properties. If that's your case there is currently no migration path but we can discuss that in an issue.

Examples are now validated again and can be replaced (#1478, #1555)

Examples used to be validated, then they were not, and now they are again, but with a specific format for schemas with references. Read the docs to know more.

Also, any new call to example() will replace previous examples, it's not additive anymore.

Lazy schemas are now less lazy by default (#1258)

Joi.lazy is now caching the result of its function call, this could lower the overhead if you were generating schemas in those. If you want to disable it for whatever reason, use Joi.lazy(fn, { once: false }).

array.min/max/length will be overridden by last call (#1127)

Joi.array().min(3).min(2) is now strictly equivalent to Joi.array().min(2), it used to be Joi.array().min(3), so now the last one wins for all those rules.

object.pattern and string.regex now preserve most of the flags (#1429)

Previously, all flags but i were ignored for regular expressions, now you can pass any flag but g (global) or y (sticky).

Single year is now parsed correctly for ISO dates (#1247)

When expecting a Joi.date().iso(), single numbers (as numbers or strings) such as '2013' were considered as epoch while the ISO format allows for that, now it's correctly considered as 2013-01-01T00:00:00.000Z.

Correctly apply labels to alternatives schemas (#1364)

Error messages could look weird when you chain a label with an alternative, say Joi.when('foo', { ... }).label('myLabel'). Now it is correctly dealt with.

Error message override is also applied to individual errors (#1568)

A value can fail for many reasons, especially if you use abortEarly: false. Error overrides used to take over for the main error message but leave alone the individual errors that were exposed in the details array. Now it is assumed that you want to override all pertaining to the same value.

✨ New features

New features were introduced as part of breaking changes, but none otherwise.

@Marsup Marsup added breaking changes Change that can breaking existing code release notes Major release documentation labels Oct 14, 2018
@Marsup Marsup added this to the 14.0.0 milestone Oct 14, 2018
@Marsup Marsup self-assigned this Oct 14, 2018
chris48s added a commit to chris48s/shields that referenced this issue Oct 28, 2018
Joi 14 throws an exception on regexes which use the `g` flag
see hapijs/joi#1615

semver-regex uses the `g` flag
https://github.com/sindresorhus/semver-regex/blob/master/index.js

so in order to upgrade Joi, I've swapped out semver-regex
We'll use joi-extension-semver for semver validation now
chris48s added a commit to badges/shields that referenced this issue Oct 28, 2018
…din-directory dynamic-xml] (#2221)

* upgrade to Joi 14
    Joi 14 throws an exception on regexes which use the `g` flag
    see hapijs/joi#1615
    semver-regex uses the `g` flag
    https://github.com/sindresorhus/semver-regex/blob/master/index.js
    so in order to upgrade Joi, I've swapped out semver-regex
    We'll use joi-extension-semver for semver validation now

* use isVPlusDottedVersionNClauses in jetbrains tests
    some of these projects use version numbers like
    v1.7 or
    v3.0.0.141
@hapijs hapijs deleted a comment from basilbattikhi Nov 11, 2018
@hapijs hapijs deleted a comment from Marsup Nov 11, 2018
@hapijs hapijs deleted a comment from basilbattikhi Nov 11, 2018
@hapijs hapijs deleted a comment from Marsup Nov 11, 2018
lucasconstantino added a commit to lucasconstantino/joi-to-swagger that referenced this issue Feb 6, 2019
lucasconstantino added a commit to lucasconstantino/joi-to-swagger that referenced this issue Feb 6, 2019
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking changes Change that can breaking existing code release notes Major release documentation
Projects
None yet
Development

No branches or pull requests

2 participants