-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
v16.0.0 Release Notes #2037
Labels
Milestone
Comments
hueniverse
added
breaking changes
Change that can breaking existing code
release notes
Major release documentation
labels
Aug 10, 2019
9 tasks
9 tasks
2 tasks
jackieluc
referenced
this issue
in momiller121/hemera
Oct 16, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Summary
joi v16.0.0 is a massive release with many changes to every corner of the module and its extensions. The entire code base has been rewritten with many new features and core components. Instead of an internal architecture and extension framework, every core type is now using the same extension system with a full extension API available for new or expanded types. Since joi schemas are usually well-defined and well-contained, it is recommended to review them against the updated reference to ensure they still perform the expected validation.
Breaking Changes
describe()
manifest format (schema.describe minor issues and feature suggestions #1606, Description changes #1823, string min/max/length description missing encoding #1827, Remove isRegExp from object.rename description #1828, Remove precision flag #1850, Remove byteAligned flag #1851, Remove trim flag #1852, Remove case flag #1853, Merge positive and negative number rules into single sign rule #1864, Replace ref.type description to ref.ref #1891, Change object.rename() from description to { regex } when using from pattern #1898, Replace raw flag with result flag in description #1921, Replace date multiple and timestamp flag with format #1977, Replace strip flag with result flag #1995, Compile valid values into valid+override #2077)func.ref()
toobject.ref()
(Move func().ref() to object().ref() #1831)items()
andordered()
) point to their own schema instead of the array they are in (Change reference view in array item rules #1832)isJoi
from schema (useJoi.isSchema()
instead) (Remove isJoi from schema #1834)convert
istrue
(Run extension coerce only if options.convert is true #1835)array.single()
regardless ofconvert
(Apply array.single() regardless of options.convert #1836)Hoek.reach()
options fromJoi.ref()
(Remove Hoek.reach() options from Ref #1839)array.single()
to only allow non-array items (Limit array.single() to only non-array items #1840)when()
calls when the first was not onalternatives
type (Forbid chaining when() calls when the first was not on alternatives type #1848)any.error()
options (Remove self option from error() #1857)this
fromany.error()
function calls (Remove this from error() function #1858)any.createOverrideError()
(Remove any.createOverrideError() #1859)options()
topreferences()
(Bidirectional describe() <-> build() #1867)string.regex()
tostring.pattern()
(Bidirectional describe() <-> build() #1867)any.error()
only supports anError
or a function that returns a singleError
(drop support for a function that returns string or array or errors (Remove support for string or array or errors return value from error() function #1869)any.createError()
, renamed and changed to$_createError(code, value, local, state, prefs, options)
(Remove flags argument from createError() #1874)object.rename('a', 'b', { override: true })
to not delete existing keyb
ifa
does not exist (Change object.rename() override option to not delete existing if nothing match #1886)Joi.ref()
was changed from a function to object withref.resolve()
method (Joi.ref() is not a function #1888)escapeHtml
preference undererrors.escapeHtml
(Replace escapeHtml with escapeErrors #1889, Move error related prefs toerrors
#1905){{!var}}
unescaped error string notation with{var}
(Replace {{!var}} notation with {var} #1890)#
prefix for error local context arguments ({{label}}
->{{#label}}
) (Change any.notes() to any.note() and require separate arguments #1983)isJoi
fromErrors.Report
(Remove isJoi from Errors.Report #1895)language.wrapArrays
toerrors.wrapArrays
preference (Rename messages.wrapArrays with wrapArrays #1901, Move error related prefs toerrors
#1905)language
preference tomessages
(Renamelanguage
preference tomessages
#1902)messages
(Remove ability to change template for implicit label prefix in error messages #1904)abortEarly
ittrue
(Unknown object keys ignore abortEarly flag #1911)Joi.validate()
andJoi.describe()
(call direct on schema instead) (Remove root.validate() and root.describe() #1941)object.type()
toobject.instance()
andany.schemaType
toany.type
(Rename object.type() to object.instance() #1942, Rename any.schemaType to any.type #1943)Joi.reach()
toschema.extract()
and throw when reaching into non-objects (Throw when Joi.reach() is reaching into non-object #1945, Replace Joi.reach() with schema.extract() #1949)applyFunctionToChildren()
(Remove applyFunctionToChildren() #1946)requiredKeys()
,optionalKeys()
, andforbiddenKeys()
(usefork()
instead) (Remove requiredKeys(), optionalKeys(), and forbiddenKeys() #1951)object.and()
) error path to always use object root (Fix object peer dependencies error path #1960)Joi.lazy()
type (useJoi.link()
instead) (Repalce lazy with link #1968)raw()
(Applyingraw
after successful validation #1972)description
argument indefault()
for functions and require value to not beundefined
(Remove description fordefault()
function #1975)only()
from an alias ofvalid()
to convertingallow()
tovalid()
(Change only() to flag instead of alias of valid() #1978)any.example()
to append by default with second argumentoptions
for override (Change any.example() to append by default #1981)any.tags()
toany.tag()
and require separate arguments (Change any.tags() to any.tag() and require separate arguments #1982)any.notes()
toany.note()
and require separate arguments (Change any.notes() to any.note() and require separate arguments #1983)Joi
to no longer be an instance ofJoi.any()
but support a some shortcuts (allow()
,disallow()
,equal()
,exist()
,forbidden()
,invalid()
,not()
,optional()
,options()
,prefs()
,preferences()
,required()
,valid()
,when()
) (Refactor root #1985)Joi.bind()
withJoi.types()
(Refactor root #1985)validate()
to sync-onlyvalidate()
and async-onlyasyncValidate()
(Split validate() to sync and async versions #1998)options
validation invalidate()
(useJoi.checkPreferences()
to manually validate once) (Remove prefs schema validation #2002)extend()
API (New extension API #2010, Expose all internal extend() options externally #2013, Rule arguments validation #2023, Support reverse order coerce #2022, Allow mapping flags to rule methods with a different name #2039)Joi.func()
toJoi.function()
(Rename func to function #2012)Joi.object()
andJoi.array()
string coerce (Remove object and array string coerce #2031)error
in syncvalidate()
result toundefined
instead ofnull
when there is no error ({ result, error } changed to error undefined instead of null #2036)boolean.insensitive()
withboolean.sensitive()
and not apply it toallow()
(Replace boolean.insensitive() with sensitive() and not apply to allow() #2040)errors.stack
preference) (Exclude error stack trace by default #2041)valid()
instead of alternatives type (Cast multi values of into a single type with valid() #2046)alternatives.when()
toalternatives.conditional()
(Rename alternatives.when() to alternatives.conditional() #2054)object.assert()
ref changed to be relative to own object value, not siblings (object.assert() ref should be relative to parent, not self #2060)any.when()
to retain same type instead of returning aJoi.alternatives()
(Support chained when() #2062)Joi.valid(Joi.override, ...value)
except forempty()
(Compile valid values into valid+override #2077)valid()
andinvalid()
(Always perform deep equal on valid() and invalid() #2088)-0
to0
(Always convert -0 to 0 #2102)Bug fixes
.
characters (Support schema keys with '.' (without forcing path reach) #1695)'https://'
and'http:/'
as an invalid urls (Joi.string().uri() accepts "https://" as a valid url #1732, Joi.string().uri() accepts 'http:/' as valid URL #1994)falsy()
ortruthy()
rules are present (truthy() / falsy() values apply when convert is false #1736)'.30'
as a valid number with coercion (Number validation fails with a valid number (".30") #1806)string.truncate()
doesn't account for max with ref (string.truncate() doesn't account for max with ref #1826)concat()
(Unique tests duplicated on concat() #1838, Behavior of .concat() with tests redefinition #1973)when()
condition (Error on unreachable when() statement #1849)object.rename()
errors when nothing has to be renamed (.rename() causes errors when nothing has to be renamed #1854)number()
errors with'0.00000095'
value (Joi.number() throws error for "0.00000095" string. #1876, contributed by Raghav Manikandan)object.rename('a', 'b', { override: true })
from deleting existing keyb
ifa
does not exist (Change object.rename() override option to not delete existing if nothing match #1886)abortEarly
flag (Unknown object keys ignore abortEarly flag #1911)keys()
(Cannot combine function rules with object keys #1919)object.and()
) error path from first key to object root (Fix object peer dependencies error path #1960)describe()
(Deep clone all values returned in describe() #1974)empty()
should allow''
if it was explicitly defined (Merging of two empty() should allow '' if it was explicitly defined #2005)string.isoDate()
fails onallow()
and inconsistent whenconvert
preference isfalse
(string.isoDate() fails on allow() and convert:false #2030)valid()
andinvalid()
references to arrays to be used as a literal array value and not array of literal values (Fix comparison of array values (literals and references) #2087)'-0'
errors as unsafe number incorrectly ("-0" throw number.unsafe #2091)'1E3'
(Number validation fails with "1E3" #2097)Updated dependencies
New Features
Official browser support
joi now comes with a pre-built minified version for client-side development. The package size has been reduced from over 500K to around 150K (uncompressed). Future releases will allow even smaller distributions by being able to pick just the needed functionality. The browser build does not include TLD email validation,
Joi.binary()
, the describe/build functionality, or debug/tracing.Manipulate referenced values in expressions (#667, #1917, #1930, #1935, #2027)
Require
b
to be equal toa
plus one:Require at least one of
a
,b
, orc
to betrue
:When
annual
istrue
, requireto
to be less than one year away fromfrom
:Validate domain names (#925)
Match domain names under the
.com
and.net
TLDs:Return typed validation errors (#1244)
Contributed by Aaron J. Lang.
joi will return or throw
ValidationError
instead of plainError
.Support multiple languages (#1866)
Override rule messages (#1264, #1877)
Proof of concept provided by David Luzar.
Modify the messages of individual rules:
Modify the messages of multiple rules:
Modify specific languages:
object.rename()
regex capture groups (#1403)Rename all keys that contain only digits to start with
'num_'
:Specify requirements for object key pattern matches (#1457, #2038)
Require an object to contain a specific number of keys starting with
'custom_'
basedon the value of another key
count
:Require all keys starting with
'x'
to be at least1
and all keys ending in'z'
to be at least10
:Require all keys starting with
'x'
to be at least1
and for all other keys ending in'z'
(but not starting with'x'
) to be at least10
:Replace invalid values with a failover value (#1535)
If a number is bigger than
10
, set it to5
:Validate ISO duration string (#1612)
Contributed by Alex Petty.
Validates ISO 8601 duration strings:
Advance references (#1569, #1650, #1695, #1702, #1807, #1865, #1979, #1993)
If an array size is
2
, all the items must be2
, otherwise7
:Require key
c
to equal its unclea
:Require key
c
to equal the absolute valuea
key (note that the root value changes when this schema is used as a sub-schema):Reference keys with
.
characters:Require the second array item to be equal or greater than the first item:
Require
a
to be two times the value ofb
by manipulating the resolved value of the reference using a function:Require
a
to be10
whenb
is5
, and11
whenb
is6
:Retain object non-enumerable properties (#1696)
Validate URI domain component (#1705, #1965)
Only allow URIs with
.com
domains and at least 3 segments (e.g.'www.example.com'
):Support validation options in
assert()
andattempt()
(#1722)Contributed by Wes Tyler.
Return all errors in assert message:
Validation value and result caching (#1727)
Proof of concept contributed by Michael McLaughlin.
Cache strings to optimize complex regex lookup for repeated values:
Support array rules validation when items rule fails (#1730)
Return all errors, including items and unique violations:
Set error language based on value in the validated object (#1737, #1907)
Return errors in the language provided within the value:
Validate URI-safe base64 strings (#1746)
Validate a URI-safe base64 string with optional padding:
Customize dates string format in error messages (#1762, 1924)
Set date error string format to date only (no time):
Validate multiple email addresses on a single line (#1812)
Contributed by Dolphin.
Enahnced
when()
options (#1860, #2078, #2079, #2099)Switch statement:
Default
is
to truthy value validation:Use
not
for reverse condition:Break processing conditions:
When strings begin with
'a'
require them to be'axxx'
, except for them they are3
characters long which must always be'abc'
:Bidirectional
describe()
<->build()
(#1867, #1986, #1987)Generates a description that is 100% representative of the schema and can be converted back into a schema:
Add
object.schema()
type support (#1873)Require the value to be a joi number schema:
Rules sets (#1877)
Change the error message of a group of rules:
Warnings (#1877, #1957, #1958)
Return a deprecation warning on unused key
y
:(Note that typically, the message definition for
deprecate.error
will be provided globally.)Convert a set of rules to generate warnings instead of errors:
Allow multiple instances of unique rules (#1877, #1881)
Keep both checks for minimum value and error based on the first rule to break:
Sort array items (#1885)
Sorts the array items in ascending order:
Verify (but not modify) the array of object is sorted in descending by the
n
object property:Value casting (#1914, #1922, #1925, #1929)
Cast the validated number to a string:
Return the validated array as
Set
:Return the validated object as
Map
:Return
1
fortrue
and0
forfalse
:Extend schema with constructor arguments (#1932)
Create a new special type that takes a minimum limit in its type constructor:
Support asynchronious operations (post-validation) (#1937)
Perform a database user id lookup on valid strings:
Extract any sub-schema with implicit and explicit identifiers (#1950, #1952)
Extract a deeply nested schema inside array items definition:
Fork schemas (#1950, #1952)
Change the deeply nested
d
schema to require a minimum value of10
:Schema alterations (#1954)
Feature designed by Nicolas Morel.
Define a single
payload
schema but tailor it to handle PUT and POST requests differently:Schema links and recursive schemas (#1968, #1979, #1993, #2080, #2084, #2096)
Replaces
Joi.lazy()
by simply referencing the part of the schema to reuse, including the root.Validate
b
using the same rules asa
(a string or a number):Validate
a.b.c.d
using the same rules asa.e.f
:Recursively validate persons and their friends and their friends, etc.:
Validate a family where each member has recursive friends:
Validate using a shared schema (that is not used elsewhere in the schema chain):
Validate
b.c
using the same rules asa
(a string or a number):Validate recursive structure
{ name: 'a', keys: [{ name: 'b', keys: [{ name: 'c', keys: [{ name: 'd' }] }] }] }
:Validate recursive root structure (root links are simpler but do not work when the schema is then reused inside another schema as the root reference will change to the new external schema):
Custom synchronious functions (#2032)
Replace
2
with3
and error on4
:Include messages in other messages (#2033)
Skip error rendering preference (#2035)
Return just the error code and improve performance when the text message is not needed:
Match only one or all alternatives (#2051)
Allow numbers and strings that can be converted to numbers, but keep the original:
Allow numbers and strings but not number strings:
Debug log (#1959)
Return a step-by-step list of internal validation processing for debugging schemas:
Allow / disallow lists override (#2076)
Replace the list of valid values:
Clear valid list and only flag:
Validate values against members of a referenced array (#2089)
Ensure
defaultValue
is one ofallowedValues
:Ensure the value of
b
is present as a key ina
object:Migration Checklist
Due to the size of this release and the sheer amount of changes, both breaking and non-breaking, it would be impossible to generate a single migration guide that will cover every possible use case.
The list below is meant as a general guide to help with common use cases and provide clues as to how to approach upgrading to this release. It is highly recommended to review every single rule being used in your code to ensure it still does what you expect. Most problems will result in a helpful error message, but not all.
Core validation workflow
The basic validation flow has changed in a few way:
convert
option istrue
(default value). This has been the case for built-in types but not for extensions.abortEarly
istrue
and an object contains unknown keys, the first key will generate an error instead of iterating through all the unknown keys. This was the expected behavior but might result in different error returned.raw()
is used in conjunction with references, the referenced value used was the raw value, not the validated value. This was changed to use the validated (and potentially coerced) value in references.Checklist:
raw()
with references to the raw key takes into account the validated value instead of the raw value.Errors and messages
TL;DR - If you do anything with errors other than pass the message along, you don't have to do much. However, if you rely on message format, error codes, or provide custom messages, you will need to revisit as it is unlikely to work as-is.
Error messages use a new template parser:
label
), they must be prefixed with#
. For example{{label}}
is now{{#label}}
).{{!var}}
syntax for unescaped variables has been replaced with{var}
.#label
variable will be set to the label of the failing schema instead of the full path.!!
prefix is no longer supported and will result in a literal!!
included in the error message. To disable labels in message templates that include it, use the newerrors.label
preference.Errors content changed throughout by applying:
dateFormat
preference set tostring
to retain the previous default.ref:global:{path}
ref:local:{path}
ref:{path}
ref:root:{path}
Other error changes:
Error
objects no longer capture the call stack by default to improve performance and since validation errors are usually coming from a known local and the call stack is unused. To generate a call stack, use theerrors.stack
preference set totrue
.reason
local error context.object.and()
) error path to always use object root instead of including the failing key in the path. Dependency errors are about the object itself, not the individual keys.The
language
preference was replaced by a newmessages
preference using a new structure:New errors codes:
alternatives.all
alternatives.match
alternatives.types
alternatives.one
any.custom
any.failover
any.ref
array.sort
array.sort.mismatching
array.sort.unsupported
date.format
number.infinity
object.pattern.match
object.refType
string.domain
string.empty
string.isoDuration
Changed errors codes:
root
- does not support templates, must be a plain string.alternatives.base
- changed toalternatives.any
.any.allowOnly
- changed toany.only
any.empty
- replaced bystring.empty
array.excludesSingle
- replaced byarray.excludes
array.includesSingle
- replaced byarray.includes
array.ref
- replaced byany.ref
date.ref
- replaced byany.ref
date.isoDate
- replaced by 'date.format'date.timestamp.javascript
- replaced by 'date.format'date.timestamp.unix
- replaced by 'date.format'function.base
- replaced byobject.base
function.ref
- replaced byany.ref
number.ref
- replaced byany.ref
object.allowUnknown
- replaced byobject.unknown
object.assert
-#ref
changed to#subject
object.rename.multiple
- added#pattern
object.rename.override
- added#pattern
object.rename.regex.multiple
- replaced byobject.rename.multiple
object.rename.regex.override
- replaced byobject.rename.regex.override
object.schema
- added#type
object.type
- replaced byobject.instance
string.email
- added#invalids
string.ref
- replaced byany.ref
string.regex.base
- replaced bystring.pattern.base
string.regex.name
- replaced bystring.pattern.name
string.regex.invert.base
- replaced bystring.pattern.invert.base
string.regex.invert.name
- replaced bystring.pattern.invert.name
Unsupported error codes:
key
- no longer supported.messages.wrapArrays
- moved toerrors.wrapArrays
preference.Schema descriptions
A key goal of joi v16 was to support a fully bidirectional describe and build format. The new format has some overlap with the previous one but the change list is far too to include here. If you use the output of
describe()
programmatically, please consult the source code for how schemas are described. Full documentation is upcoming.Please note that the description manifest is not designed to be wire-friendly due to the fact that many methods support functions and symbols which do not have a JSON representation. Converting functions to strings is not practical or secure. If you plan on using the new manifest system to send text schemas across the network, make sure to only use wire-safe features which do not include functions, symbols, or other unsupported primitives.
Extensions
The entire extension system has been replaced with a new framework that is now at the core of the entire type system. Every built-in type is just an extension of the base type. Everything the built-in types can do is now available to extensions. Migrating existing extensions is outside the scope of this guide. Please consult the documentation when it becomes available. However, the best resource is the joi built-in types code base.
Array and object string coercion
Joi.object()
andJoi.array()
no longer support string coercion. This means that a string value of'[1,2,3]'
will no longer be automatically converted to a valid array whenconvert
istrue
, and similarly for objects. This could be a problem if you support object or array strings in HTTP request query strings.Use extensions to restore this functionality, for example:
Schema compilation
When using
Joi.compile()
explicitly or passing non-schema keys and performing implicit compile (e.g.Joi.object({ a: 'x' })
), the schema compilation step will no longer compile literals into a type matching strings, booleans, or numbers. Instead, it will return aJoi.any()
type with exact literal set asvalid()
. This meansJoi.object({ a: 5 })
will no longer match{ a: '5' }
. In addition, compiling an array of literal values will compile into a single any type withvalid()
instead of alternatives type.When compiling literal values into
valid()
, the override flag will be added which will make the value override anything it is being concatenated to (e.g. when used inany.when()
). To avoid the default override behavior, pass an explicitJoi.valid()
schema in stead of a literal value. For example,'x'
is compiled intoJoi.valid(Joi.override, 'x')
, butJoi.valid('x')
is left unchanged. The only exception is for values passed to theJoi.empty()
function which are not set to override.To keep the previous behavior pass the exact types you want instead of relying on implicit compiling.
API changes
Root module methods
Joi.allow()
any.allow()
changes.Joi.bind()
Joi.types()
.Joi.concat()
Joi.any().concat()
instead (and consult its own changes).Joi.compile()
Joi.any()
is returned instead of the matching type. This meansJoi.compile(5)
will no longer match'5'
. To keep the previous behavior pass explicit schemas. See Schema compilation section above.Joi.createError()
any.$_createError()
instead.Joi.createOverrideError()
Joi.default()
Joi.any().default()
instead (and consult its own changes).Joi.describe()
schema.describe()
directly on the compiled schema.Joi.description()
Joi.any().description()
instead.Joi.disallow()
any.disallow()
changes.Joi.empty()
Joi.any().empty()
instead.Joi.equal()
any.equal()
changes.Joi.error()
Joi.any().error()
instead (and consult its own changes).Joi.example()
Joi.any().example()
instead (and consult its own changes).Joi.func()
Joi.function()
.Joi.invalid()
any.invalid()
changes.Joi.label()
Joi.any().label()
instead.Joi.lazy()
Joi.link()
instead.Joi.meta()
Joi.any().meta()
instead.Joi.not()
any.not()
changes.Joi.notes()
Joi.any().note()
instead.Joi.only()
Joi.valid()
instead (and consult its own changes).Joi.options()
Joi.preferences()
.any.options()
changes.Joi.raw()
Joi.any().raw()
instead.Joi.reach()
schema.extract()
directly on the compiled schema.Joi.ref()
Hoek.reach()
options inoptions
.Joi.schemaType
Joi.any().type
instead.Joi.strict()
Joi.any().strict()
instead.Joi.strip()
Joi.any().strip()
instead.Joi.tags()
Joi.any().tag()
instead.Joi.unit()
Joi.any().unit()
instead.Joi.valid()
any.valid()
changes.Joi.validate()
schema.validate()
directly on the compiled schema.any.validate()
changes.Joi.when()
any.when()
changes.any()
methods (applies to all types)any.allow()
any.applyFunctionToChildren()
any.concat()
min()
,max()
) are no longer retained and are replaced by the source concatenated schema.any.createError()
any.$_createError()
instead.any.createOverrideError()
any.default()
description
argument.undefined
as value.literal
option set totrue
.any.disallow()
any.invalid()
any.equal()
any.valid()
any.error()
options
.this
.Error
instance or a function that returns a singleError
instance.any.example()
options
for tooverride
existing examples.any.invalid()
Joi.in()
method.Hoek.deepEqual()
method instead of shallow comparison.any.isJoi
Joi.isSchema()
instead.any.not()
any.invalid()
any.notes()
any.note()
.any.only()
valid()
and must be replaced withany.valid()
(and consult its own changes).any.allow()
rules to behave as ifany.valid()
was used.any.options()
preferences()
.options
changes listed underany.validate()
.Joi.schemaType
any.type
instead.any.tags()
any.tag()
.any.valid()
Joi.in()
method.Hoek.deepEqual()
method instead of shallow comparison.any.validate()
{ value, error, warning }
. For Promises support, use newany.asyncValidate()
.error
changed toundefined
fromnull
.options
object is no longer validated automatically. UseJoi.checkPreferences()
to manually validate once.options.language
no longer supported. Use newoptions.messages
.options.escapeHtml
tooptions.errors.escapeHtml
.options.language.wrapArrays
toerrors.wrapArrays
.any.when()
Joi.alternatives()
type. The same type is retained and the condition is applied during validation time to generate a custom schema based on the combination of the multiplewhen()
statements defined.when()
conditions once the first one matched. This is no longer the case and all thewhen()
statements are processed. If you compare the same reference in chainedwhen()
s, keep in mind that it will match both the value and anyotherwise
statements which is probably not what you want. Use the newswitch
statement to only match a single schema.when()
types (e.g. string type rules applied to number type base) will throw an error during validation so make sure to review your schema for potential conflicts.is
,then
,otherwise
literal values are compiled into override schemas ('x'
is compiled intoJoi.valid(Joi.override, 'x')
). This means they will override any base schema the rule is applied to. To add a literal value, use the explicitJoi.valid('x')
format.alternatives()
methodsalternatives()
alternatives.try()
alternatives.when()
any.when()
with a different implementation. Usealternatives.conditional()
instead to keep existing behavior.array()
methodsarray()
array.items()
...
to reference the array itself.array.ordered()
...
to reference the array itself.array.single()
convert
.binary()
methodsbinary.min()
binary.max()
binary.length()
boolean()
methodsboolean.insensitive()
boolean.sensitive()
instead.boolean.allow()
boolean.equal()
boolean.falsy()
boolean.invalid()
boolean.not()
boolean.truthy()
boolean.valid()
date
methodsdate.min()
date.max()
date.greater()
date.less()
function
methodsfunction.arity()
function.class()
function.maxArity()
function.minArity()
function.ref()
object.ref()
number()
methodsnumber.greater()
number.integer()
number.less()
number.max()
number.min()
number.negative()
number.port()
number.positive()
number.precision()
object()
methodsobject()
object.and()
object.assert()
.
as a prefix to the subject reference (e.g. change'a.b'
to.a.b
). No change on references resolved inside the assertion schema condition.object.forbiddenKeys()
any.fork()
instead.object.length()
object.max()
object.min()
object.nand()
object.optionalKeys()
any.fork()
instead.object.or()
object.pattern()
fallthrough
option to keep previous behavior.object.rename()
rename('a', 'b', { override: true })
will no longer delete existing keyb
ifa
does not exist.object.requiredKeys()
any.fork()
instead.object.schema()
object.type()
object.instance()
object.xor()
ref()
methodsJoi.ref()
was changed from a function to object withref.resolve()
method.Joi.ref()
no longer supportsHoek.reach()
options.string()
methodsstring.alphanum()
string.base64()
string.creditCard()
string.dataUri()
string.email()
string.guid()
string.hex()
string.hostname()
string.ip()
string.isoDate()
string.length()
string.lowercase()
string.max()
string.min()
string.normalize()
string.regex()
string.pattern()
.string.trim()
string.uppercase()
string.token()
string.uri()
string.uuid()
The text was updated successfully, but these errors were encountered: