Skip to content

10.0.0 Release Notes #1037

@Marsup

Description

@Marsup

Summary

This release breaks Joi.boolean() behavior and extracts Joi.date().format() in an external module.

  • Upgrade time: moderate
  • Complexity: low
  • Risk: moderate

Breaking changes

Joi.boolean()

In the previous versions, with convert set to true, Joi supported the use of equivalent values for true or false, namely "true", "false", "yes", "no", "on", "off", 1, 0, "1" and "0". This is not the case anymore, it will only support true, false, "true" and "false" by default, with the possibility to disable string conversion by using strict(). There are now escape hatches for the other cases if you still want this, so the previous schema can now be expressed as :

Joi.boolean().truthy('yes', 1, '1').falsy('no', 0, '0')

You can put any value in those if you want, though it will not try to do a deep comparison.

Removal of Joi.date().format()

Removing this was important to streamline the core of joi, it didn't make much sense to impose moment on you when you might not even be using it. It might as well simplify the bundling process if you were using joi through webpack/browserify/rollup/....

You can still get the feature by using joi-date-extensions, read the docs there about how to use it. The behavior should be very close to previous joi versions, though I can't absolutely it is strictly the same, as I tried to not only split code but do an extension that "felt right". If it's not perfect, don't worry, having it in a separate module will allow it to evolve way more quickly than joi core can.

New features

Joi.version

Exposes the version of the joi module being used, could be useful for some operations or debugging.

Joi.string().uri({ relativeOnly: true })

Now the URI check accepts a new option to validate only relative URIs.

Joi.string().base64()

As the name says, it checks whether a string is a valid base64 string.

Joi.string().regex(pattern, name | options)

The regex rule can now take an options object that can contain :

  • name : as before, the friendly name of the regular expression.
  • invert : a new boolean flag that indicates whether we want to match the regular expression, or its opposite. It obviously defaults to false.

Contributors

The contributors to this release are @WesTyler, @lamchakchan, @chris--young, @ptrckc and myself.

Metadata

Metadata

Assignees

Labels

breaking changesChange that can breaking existing coderelease notesMajor release documentation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions