]]>
+ https://github.com/hapijs/tlds/milestone/14
diff --git a/docs/resources/index.md b/docs/resources/index.md
index 56237f3..5645a5d 100644
--- a/docs/resources/index.md
+++ b/docs/resources/index.md
@@ -1,12 +1,12 @@
---
layout: false
head:
- - - meta
- - http-equiv: refresh
- content: 0; url=/resources/changelog
- - - script
- - {}
- - "window.location.replace('/resources/changelog');"
+ - - meta
+ - http-equiv: refresh
+ content: 0; url=/resources/changelog
+ - - script
+ - {}
+ - "window.location.replace('/resources/changelog');"
---
Redirecting to Changelog...
diff --git a/docs/tester/[version].paths.ts b/docs/tester/[version].paths.ts
index b45a06e..055e2d8 100644
--- a/docs/tester/[version].paths.ts
+++ b/docs/tester/[version].paths.ts
@@ -1,23 +1,23 @@
import { defineRoutes } from 'vitepress';
-import joiInfo from '../../generated/modules/joi/info.json' with { type: 'json' };
+import JoiInfo from '../../generated/modules/joi/info.json' with { type: 'json' };
import type { ModuleInfo } from '../../cli/types.js';
export default defineRoutes({
- paths() {
- const info = joiInfo as ModuleInfo;
- const versions = info.versionsArray
- .map((v) => parseInt(v.split('.')[0], 10))
- .map((major) => ({
- params: { version: `${major}.x.x` },
- }));
+ paths() {
+ const info = JoiInfo as ModuleInfo;
+ const versions = info.versionsArray
+ .map((v) => parseInt(v.split('.')[0], 10))
+ .map((major) => ({
+ params: { version: `${major}.x.x` },
+ }));
- // Also handle the base /tester path
- versions.push({
- params: { version: 'index' },
- });
+ // Also handle the base /tester path
+ versions.push({
+ params: { version: 'index' },
+ });
- return versions;
- },
+ return versions;
+ },
});
diff --git a/env.d.ts b/env.d.ts
index cfab8ba..8461884 100644
--- a/env.d.ts
+++ b/env.d.ts
@@ -1,13 +1,13 @@
declare module '*.vue' {
- import type { DefineComponent } from 'vue';
- // oxlint-disable-next-line typescript/ban-types
- const component: DefineComponent<{}, {}, any>;
- export default component;
+ import type { DefineComponent } from 'vue';
+ // oxlint-disable-next-line typescript/ban-types
+ const component: DefineComponent<{}, {}, any>;
+ export default component;
}
declare module '*?raw' {
- const content: string;
- export default content;
+ const content: string;
+ export default content;
}
declare module '*.css' {}
diff --git a/generated/markdown/address/5/api.md b/generated/markdown/address/5/api.md
index c70c780..ed334be 100644
--- a/generated/markdown/address/5/api.md
+++ b/generated/markdown/address/5/api.md
@@ -6,12 +6,12 @@ Analyzes a string to verify it is a valid domain name where:
- `domain` - the domain name string being verified.
- `options` - optional settings:
- - `allowUnicode` - if `false`, Unicode characters are not allowed in domain names. Defaults to `true`.
- - `allowUnderscore` - if `false`, underscore (`_`) characters will not be allowed in the domain name. Defaults to `false`.
- - `minDomainSegments` - the minimum number of domain segments (e.g. `x.y.z` has 3 segments) required. Defaults to `2`.
- - `tlds` - options to validate the top-level-domain segment (e.g. `com` in `example.com`) where:
- - `deny` - a `Set` with strings matching forbidden TLD values (all non-matching values are allowed).
- - `allow` - a `Set` with strings matching the only allowed TLD values.
+ - `allowUnicode` - if `false`, Unicode characters are not allowed in domain names. Defaults to `true`.
+ - `allowUnderscore` - if `false`, underscore (`_`) characters will not be allowed in the domain name. Defaults to `false`.
+ - `minDomainSegments` - the minimum number of domain segments (e.g. `x.y.z` has 3 segments) required. Defaults to `2`.
+ - `tlds` - options to validate the top-level-domain segment (e.g. `com` in `example.com`) where:
+ - `deny` - a `Set` with strings matching forbidden TLD values (all non-matching values are allowed).
+ - `allow` - a `Set` with strings matching the only allowed TLD values.
If the `domain` is valid, no return value. If the `domain` is invalid, an object is returned with:
@@ -30,13 +30,13 @@ Analyzes a string to verify it is a valid email address where:
- `email` - the email address string being verified.
- `options` - optional settings:
- - `allowUnicode` - if `false`, Unicode characters are not allowed in the email address local and domain parts. Defaults to `true`.
- - `allowUnderscore` - if `false`, underscore (`_`) characters will not be allowed in the domain name. Defaults to `false`.
- - `ignoreLength` - if `true`, the standards email maximum length limit is ignored. Defaults to `true`.
- - `minDomainSegments` - the minimum number of domain segments (e.g. `x.y.z` has 3 segments) required in the domain part. Defaults to `2`.
- - `tlds` - options to validate the top-level-domain segment (e.g. `com` in `example.com`) where:
- - `deny` - a `Set` with strings matching forbidden TLD values (all non-matching values are allowed).
- - `allow` - a `Set` with strings matching the only allowed TLD values.
+ - `allowUnicode` - if `false`, Unicode characters are not allowed in the email address local and domain parts. Defaults to `true`.
+ - `allowUnderscore` - if `false`, underscore (`_`) characters will not be allowed in the domain name. Defaults to `false`.
+ - `ignoreLength` - if `true`, the standards email maximum length limit is ignored. Defaults to `true`.
+ - `minDomainSegments` - the minimum number of domain segments (e.g. `x.y.z` has 3 segments) required in the domain part. Defaults to `2`.
+ - `tlds` - options to validate the top-level-domain segment (e.g. `com` in `example.com`) where:
+ - `deny` - a `Set` with strings matching forbidden TLD values (all non-matching values are allowed).
+ - `allow` - a `Set` with strings matching the only allowed TLD values.
If the `email` is valid, no return value. If the `email` is invalid, an object is returned with:
diff --git a/generated/markdown/formula/3/api.md b/generated/markdown/formula/3/api.md
index 3964689..b47f30f 100644
--- a/generated/markdown/formula/3/api.md
+++ b/generated/markdown/formula/3/api.md
@@ -4,21 +4,21 @@
const Formula = require('@hapi/formula');
const functions = {
- x: (value) => value + 10,
+ x: (value) => value + 10,
};
const constants = {
- Z: 100,
+ Z: 100,
};
const reference = function (name) {
- return (context) => context[name];
+ return (context) => context[name];
};
const formula = new Formula.Parser('1 + a.b.c.2.4.x + [b] + x([y + 4] + Z)', {
- functions,
- constants,
- reference,
+ functions,
+ constants,
+ reference,
});
formula.evaluate({ 'a.b.c.2.4.x': 2, b: 3, 'y + 4': 5 }); // 1 + 2 + 3 + 5 + 10 + 100
@@ -33,10 +33,10 @@ Creates a new formula parser object where:
- `formula` - the formula string to parse.
- `options` - optional settings:
- - `constants` - a hash of key-value pairs used to convert constants to values.
- - `tokenRx` - a regular expression used to validate token variables.
- - `reference` - a variable resolver factory function with signature `function(variable)` which returns a function with signature `function(context)` returning the resolved `variable`.
- - `functions` - a hash of key-value pairs used to resolve formula functions.
+ - `constants` - a hash of key-value pairs used to convert constants to values.
+ - `tokenRx` - a regular expression used to validate token variables.
+ - `reference` - a variable resolver factory function with signature `function(variable)` which returns a function with signature `function(context)` returning the resolved `variable`.
+ - `functions` - a hash of key-value pairs used to resolve formula functions.
### `parser.evaluate([context])`
diff --git a/generated/markdown/joi/17/api.md b/generated/markdown/joi/17/api.md
index c731540..e284a83 100644
--- a/generated/markdown/joi/17/api.md
+++ b/generated/markdown/joi/17/api.md
@@ -8,24 +8,24 @@
const Joi = require('joi');
const schema = Joi.object({
- username: Joi.string().alphanum().min(3).max(30).required(),
+ username: Joi.string().alphanum().min(3).max(30).required(),
- password: Joi.string().pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')),
+ password: Joi.string().pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')),
- repeat_password: Joi.ref('password'),
+ repeat_password: Joi.ref('password'),
- access_token: [Joi.string(), Joi.number()],
+ access_token: [Joi.string(), Joi.number()],
- birth_year: Joi.number().integer().min(1900).max(2013),
+ birth_year: Joi.number().integer().min(1900).max(2013),
- email: Joi.string().email({
- minDomainSegments: 2,
- tlds: { allow: ['com', 'net'] },
- }),
+ email: Joi.string().email({
+ minDomainSegments: 2,
+ tlds: { allow: ['com', 'net'] },
+ }),
})
- .with('username', 'birth_year')
- .xor('password', 'access_token')
- .with('password', 'repeat_password');
+ .with('username', 'birth_year')
+ .xor('password', 'access_token')
+ .with('password', 'repeat_password');
schema.validate({ username: 'abc', birth_year: 1994 });
// -> { value: { username: 'abc', birth_year: 1994 } }
@@ -36,33 +36,33 @@ schema.validate({});
// Also -
try {
- const value = await schema.validateAsync({
- username: 'abc',
- birth_year: 1994,
- });
+ const value = await schema.validateAsync({
+ username: 'abc',
+ birth_year: 1994,
+ });
} catch (err) {}
```
The above schema defines the following constraints:
- `username`
- - a required string
- - must contain only alphanumeric characters
- - at least 3 characters long but no more than 30
- - must be accompanied by `birth_year`
+ - a required string
+ - must contain only alphanumeric characters
+ - at least 3 characters long but no more than 30
+ - must be accompanied by `birth_year`
- `password`
- - an optional string
- - must satisfy the custom regex pattern
- - cannot appear together with `access_token`
- - must be accompanied by `repeat_password` and equal to it
+ - an optional string
+ - must satisfy the custom regex pattern
+ - cannot appear together with `access_token`
+ - must be accompanied by `repeat_password` and equal to it
- `access_token`
- - an optional, unconstrained string or number
+ - an optional, unconstrained string or number
- `birth_year`
- - an integer between 1900 and 2013
+ - an integer between 1900 and 2013
- `email`
- - a valid email address string
- - must have two domain parts e.g. `example.com`
- - TLD must be `.com` or `.net`
+ - a valid email address string
+ - must have two domain parts e.g. `example.com`
+ - TLD must be `.com` or `.net`
### General Usage
@@ -72,7 +72,7 @@ First, a schema is constructed using the provided types and constraints:
```js
const schema = Joi.object({
- a: Joi.string(),
+ a: Joi.string(),
});
```
@@ -100,7 +100,7 @@ the module converts it internally to an object() type equivalent to:
```js
const schema = Joi.object().keys({
- a: Joi.string(),
+ a: Joi.string(),
});
```
@@ -108,17 +108,17 @@ When validating a schema:
- Values (or keys in case of objects) are optional by default.
- ```js
- Joi.string().validate(undefined); // validates fine
- ```
+ ```js
+ Joi.string().validate(undefined); // validates fine
+ ```
- To disallow this behavior, you can either set the schema as `required()`, or set `presence` to `"required"` when passing `options`:
+ To disallow this behavior, you can either set the schema as `required()`, or set `presence` to `"required"` when passing `options`:
- ```js
- Joi.string().required().validate(undefined);
- // or
- Joi.string().validate(undefined, /* options */ { presence: 'required' });
- ```
+ ```js
+ Joi.string().required().validate(undefined);
+ // or
+ Joi.string().validate(undefined, /* options */ { presence: 'required' });
+ ```
- Strings are utf-8 encoded by default.
- Rules are defined in an additive fashion and evaluated in order, first the inclusive rules, then the exclusive rules.
@@ -156,8 +156,8 @@ Provisions a simple LRU cache for caching simple inputs (`undefined`, `null`, st
booleans) where:
- `options` - optional settings:
- - `max` - number of items to store in the cache before the least used items are dropped.
- Defaults to `1000`.
+ - `max` - number of items to store in the cache before the least used items are dropped.
+ Defaults to `1000`.
### `checkPreferences(prefs)`
@@ -179,10 +179,10 @@ Converts literal schema definition to **joi** schema object (or returns the same
- `schema` - the schema definition to compile.
- `options` - optional settings:
- - `legacy` - if `true` and the provided schema is (or contains parts) using an older version of
- **joi**, will return a compiled schema that is compatible with the older version. If `false`,
- the schema is always compiled using the current version and if older schema components are
- found, an error is thrown.
+ - `legacy` - if `true` and the provided schema is (or contains parts) using an older version of
+ **joi**, will return a compiled schema that is compatible with the older version. If `false`,
+ the schema is always compiled using the current version and if older schema components are
+ found, an error is thrown.
```js
const definition = ['key', 5, { a: true, b: [/^a/, 'boom'] }];
@@ -191,15 +191,15 @@ const schema = Joi.compile(definition);
// Same as:
const schema = Joi.alternatives().try(
- Joi.string().valid('key'),
- Joi.number().valid(5),
- Joi.object({
- a: Joi.boolean().valid(true),
- b: Joi.alternatives().try(
- Joi.string().pattern(/^a/),
- Joi.string().valid('boom'),
- ),
- }),
+ Joi.string().valid('key'),
+ Joi.number().valid(5),
+ Joi.object({
+ a: Joi.boolean().valid(true),
+ b: Joi.alternatives().try(
+ Joi.string().pattern(/^a/),
+ Joi.string().valid('boom'),
+ ),
+ }),
);
```
@@ -212,14 +212,14 @@ where:
```js
const custom = Joi.defaults((schema) => {
- switch (schema.type) {
- case 'string':
- return schema.allow('');
- case 'object':
- return schema.min(1);
- default:
- return schema;
- }
+ switch (schema.type) {
+ case 'string':
+ return schema.allow('');
+ case 'object':
+ return schema.min(1);
+ default:
+ return schema;
+ }
});
const schema = custom.object(); // Returns Joi.object().min(1)
@@ -232,7 +232,7 @@ Generates a dynamic expression using a template string where:
- `template` - the template string using the [template syntax](#template-syntax).
- `options` - optional settings used when creating internal references. Supports the same options
as [`ref()`](#refkey-options), in addition to those options:
- - `functions` - an object with keys being function names and values being their implementation that will be executed when used in the expression. Using the same name as a built-in function will result in a local override. Note: carefully check your arguments depending on the situation where the expression is used.
+ - `functions` - an object with keys being function names and values being their implementation that will be executed when used in the expression. Using the same name as a built-in function will result in a local override. Note: carefully check your arguments depending on the situation where the expression is used.
#### Template syntax
@@ -282,8 +282,8 @@ Can only be used in rules that support in-references.
```js
const schema = Joi.object({
- a: Joi.array().items(Joi.number()),
- b: Joi.number().valid(Joi.in('a')),
+ a: Joi.array().items(Joi.number()),
+ b: Joi.number().valid(Joi.in('a')),
});
```
@@ -319,7 +319,7 @@ Checks whether or not the provided argument is a **joi** schema where:
- `schema` - the value being checked.
- `options` - optional settings:
- - `legacy` - if `true`, will identify schemas from older versions of joi, otherwise will throw an error. Defaults to `false`.
+ - `legacy` - if `true`, will identify schemas from older versions of joi, otherwise will throw an error. Defaults to `false`.
```js
const schema = Joi.any();
@@ -354,27 +354,27 @@ References support the following arguments:
- `key` - the reference target. References can point to sibling keys (`a.b`) or ancestor keys (`...a.b`) using the `.` separator. If a `key` starts with `$` is signifies a context reference which is looked up in the `context` option object. The `key` can start with one or more separator characters to indicate a [relative starting point](#Relative-references).
- `options` - optional settings:
- - `adjust` - a function with the signature `function(value)` where `value` is the resolved reference value and the return value is the adjusted value to use. For example `(value) => value + 5` will add 5 to the resolved value. Note that the `adjust` feature will not perform any type validation on the adjusted value and it must match the value expected by the rule it is used in. Cannot be used with `map`.
- - `map` - an array of array pairs using the format `[[key, value], [key, value]]` used to maps the resolved reference value to another value. If the resolved value is not in the map, it is returned as-is. Cannot be used with `adjust`.
- - `prefix` - overrides default prefix characters key string prefix. Can be set to `false` to disable all prefix parsing (treat keys as literal strings), or an object with specific overrides for:
- - `global` - references to the globally provided `context` preference. Defaults to `'$'`.
- - `local` - references to error-specific or rule specific context. Defaults to `'#'`.
- - `root` - references to the root value being validated. Defaults to `'/'`.
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `ancestor` - if set to a number, sets the reference [relative starting point](#Relative-references). Cannot be combined with separator prefix characters. Defaults to the reference key prefix (or `1` if none present).
- - `in` - creates an [in-reference](#inref-options).
- - `iterables` - when `true`, the reference resolves by reaching into maps and sets.
- - `render` - when `true`, the value of the reference is used instead of its name in error messages and template rendering. Defaults to `false`.
+ - `adjust` - a function with the signature `function(value)` where `value` is the resolved reference value and the return value is the adjusted value to use. For example `(value) => value + 5` will add 5 to the resolved value. Note that the `adjust` feature will not perform any type validation on the adjusted value and it must match the value expected by the rule it is used in. Cannot be used with `map`.
+ - `map` - an array of array pairs using the format `[[key, value], [key, value]]` used to maps the resolved reference value to another value. If the resolved value is not in the map, it is returned as-is. Cannot be used with `adjust`.
+ - `prefix` - overrides default prefix characters key string prefix. Can be set to `false` to disable all prefix parsing (treat keys as literal strings), or an object with specific overrides for:
+ - `global` - references to the globally provided `context` preference. Defaults to `'$'`.
+ - `local` - references to error-specific or rule specific context. Defaults to `'#'`.
+ - `root` - references to the root value being validated. Defaults to `'/'`.
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `ancestor` - if set to a number, sets the reference [relative starting point](#Relative-references). Cannot be combined with separator prefix characters. Defaults to the reference key prefix (or `1` if none present).
+ - `in` - creates an [in-reference](#inref-options).
+ - `iterables` - when `true`, the reference resolves by reaching into maps and sets.
+ - `render` - when `true`, the value of the reference is used instead of its name in error messages and template rendering. Defaults to `false`.
Note that references can only be used where explicitly supported such as in `valid()` or `invalid()` rules. If upwards (parents) references are needed, use [`object.assert()`](#objectassertref-schema-message).
```js
const schema = Joi.object({
- a: Joi.ref('b.c'),
- b: {
- c: Joi.any(),
- },
- c: Joi.ref('$x'),
+ a: Joi.ref('b.c'),
+ b: {
+ c: Joi.any(),
+ },
+ c: Joi.ref('$x'),
});
await schema.validateAsync({ a: 5, b: { c: 5 } }, { context: { x: 5 } });
@@ -481,7 +481,7 @@ const Joi = require('joi');
const { object, string } = Joi.types();
const schema = object.keys({
- property: string.min(4),
+ property: string.min(4),
});
```
@@ -515,8 +515,8 @@ To create an exclusive list of values, see [`any.valid(value)`](#anyvalidvalues-
```js
const schema = {
- a: Joi.any().allow('a'),
- b: Joi.any().allow('b', 'B'),
+ a: Joi.any().allow('a'),
+ b: Joi.any().allow('b', 'B'),
};
```
@@ -530,10 +530,10 @@ is called where:
```js
const schema = Joi.object({
- key: Joi.string().alter({
- get: (schema) => schema.required(),
- post: (schema) => schema.forbidden(),
- }),
+ key: Joi.string().alter({
+ get: (schema) => schema.required(),
+ post: (schema) => schema.forbidden(),
+ }),
});
const getSchema = schema.tailor('get');
@@ -548,10 +548,10 @@ Assigns the schema an artifact id which is included in the validation result if
```js
const schema = {
- a: [
- Joi.number().max(10).artifact('under'),
- Joi.number().min(11).artifact('over'),
- ],
+ a: [
+ Joi.number().max(10).artifact('under'),
+ Joi.number().min(11).artifact('over'),
+ ],
};
```
@@ -599,10 +599,10 @@ Note that `key` and `value` can be anything including objects, array, etc. It is
Casts the validated value to the specified type where:
- `to` - the value target type. Each **joi** schema type supports its own set of cast targets:
- - `'map'` - supported by the `Joi.object()` type, converts the result to a `Map` object containing the object key-value pairs.
- - `'number'` - supported by `Joi.boolean()` and `Joi.date()`, converts the result to a number. For dates, number of milliseconds since the epoch and for booleans, `0` for `false` and `1` for `true`.
- - `'set'` - supported by the `Joi.array()` type, converts the result to a `Set` object containing the array values.
- - `'string'` - supported by `Joi.binary()`, `Joi.boolean()`, `Joi.date()`, and `Joi.number()`, converts the result to a string.
+ - `'map'` - supported by the `Joi.object()` type, converts the result to a `Map` object containing the object key-value pairs.
+ - `'number'` - supported by `Joi.boolean()` and `Joi.date()`, converts the result to a number. For dates, number of milliseconds since the epoch and for booleans, `0` for `false` and `1` for `true`.
+ - `'set'` - supported by the `Joi.array()` type, converts the result to a `Set` object containing the array values.
+ - `'string'` - supported by `Joi.binary()`, `Joi.boolean()`, `Joi.date()`, and `Joi.number()`, converts the result to a string.
#### `any.concat(schema)`
@@ -621,42 +621,42 @@ const ab = a.concat(b);
Adds a custom validation function to execute arbitrary code where:
- `method` - the custom (synchronous only) validation function using signature `function(value, helpers)` where:
- - `value` - the value being validated.
- - `helpers` - an object with the following helpers:
- - `schema` - the current schema.
- - `state` - the current validation state.
- - `prefs` - the current preferences.
- - `original` - the original value passed into validation before any conversions.
- - `error(code, [local], [localState])` - a method to generate error codes using a message code, optional local context and optional validation local state.
- - `message(messages, [local])` - a method to generate an error with an internal `'custom'` error code and the provided messages object to use as override. Note that this is much slower than using the preferences `messages` option but is much simpler to write when performance is not important.
- - `warn(code, [local])` - a method to add a warning using a message code and optional local context.
+ - `value` - the value being validated.
+ - `helpers` - an object with the following helpers:
+ - `schema` - the current schema.
+ - `state` - the current validation state.
+ - `prefs` - the current preferences.
+ - `original` - the original value passed into validation before any conversions.
+ - `error(code, [local], [localState])` - a method to generate error codes using a message code, optional local context and optional validation local state.
+ - `message(messages, [local])` - a method to generate an error with an internal `'custom'` error code and the provided messages object to use as override. Note that this is much slower than using the preferences `messages` option but is much simpler to write when performance is not important.
+ - `warn(code, [local])` - a method to add a warning using a message code and optional local context.
Note: if the method fails to return a value, the value will be unset or returned as `undefined`.
```js
const method = (value, helpers) => {
- // Throw an error (will be replaced with 'any.custom' error)
- if (value === '1') {
- throw new Error('nope');
- }
-
- // Replace value with a new value
- if (value === '2') {
- return '3';
- }
-
- // Use error to return an existing error code
- if (value === '4') {
- return helpers.error('any.invalid');
- }
-
- // Override value with undefined to unset
- if (value === '5') {
- return undefined;
- }
-
- // Return the value unchanged
- return value;
+ // Throw an error (will be replaced with 'any.custom' error)
+ if (value === '1') {
+ throw new Error('nope');
+ }
+
+ // Replace value with a new value
+ if (value === '2') {
+ return '3';
+ }
+
+ // Use error to return an existing error code
+ if (value === '4') {
+ return helpers.error('any.invalid');
+ }
+
+ // Override value with undefined to unset
+ if (value === '5') {
+ return undefined;
+ }
+
+ // Return the value unchanged
+ return value;
};
const schema = Joi.string().custom(method, 'custom validation');
@@ -669,11 +669,11 @@ Possible validation errors: [`any.custom`](#anycustom)
Sets a default value if the original value is `undefined` where:
- `value` - the default value. One of:
- - a literal value (string, number, object, etc.).
- - a [references](#refkey-options).
- - a function which returns the default value using the signature `function(parent, helpers)` where:
- - `parent` - a clone of the object containing the value being validated. Note that since specifying a `parent` argument performs cloning, do not declare format arguments if you are not using them.
- - `helpers` - same as those described in [`any.custom()`](#anycustommethod_description).
+ - a literal value (string, number, object, etc.).
+ - a [references](#refkey-options).
+ - a function which returns the default value using the signature `function(parent, helpers)` where:
+ - `parent` - a clone of the object containing the value being validated. Note that since specifying a `parent` argument performs cloning, do not declare format arguments if you are not using them.
+ - `helpers` - same as those described in [`any.custom()`](#anycustommethod_description).
When called without any `value` on an object schema type, a default value will be automatically generated based on the default values of the object keys.
@@ -681,22 +681,22 @@ Note that if `value` is an object, any changes to the object after `default()` i
```js
const generateUsername = (parent, helpers) => {
- return parent.firstname.toLowerCase() + '-' + parent.lastname.toLowerCase();
+ return parent.firstname.toLowerCase() + '-' + parent.lastname.toLowerCase();
};
generateUsername.description = 'generated username';
const schema = Joi.object({
- username: Joi.string().default(generateUsername),
- firstname: Joi.string(),
- lastname: Joi.string(),
- created: Joi.date().default(Date.now),
- status: Joi.string().default('registered'),
+ username: Joi.string().default(generateUsername),
+ firstname: Joi.string(),
+ lastname: Joi.string(),
+ created: Joi.date().default(Date.now),
+ status: Joi.string().default('registered'),
});
const { value } = schema.validate({
- firstname: 'Jane',
- lastname: 'Doe',
+ firstname: 'Jane',
+ lastname: 'Doe',
});
// value.status === 'registered'
@@ -732,7 +732,7 @@ Annotates the key where:
```js
const schema = Joi.any().description(
- 'this key will match anything you give it',
+ 'this key will match anything you give it',
);
```
@@ -754,8 +754,8 @@ schema.validate(''); // returns { error: "value" is not allowed to be empty, val
Overrides the default **joi** error with a custom error if the rule fails where:
- `err` can be:
- - an instance of `Error` - the override error.
- - a function with the signature `function(errors)`, where `errors` is an array of validation reports and it returns either a single `Error` or an array of validation reports.
+ - an instance of `Error` - the override error.
+ - a function with the signature `function(errors)`, where `errors` is an array of validation reports and it returns either a single `Error` or an array of validation reports.
Do not use this method if you are simply trying to override the error message - use `any.message()` or `any.messages()` instead. This method is designed to override the **joi** validation error and return the exact override provided. It is useful when you want to return the result of validation directly (e.g. when using with a **hapi** server) and want to return a different HTTP error code than 400.
@@ -768,28 +768,28 @@ schema.validate(3); // returns Error('Was REALLY expecting a string')
```js
const schema = Joi.object({
- foo: Joi.number()
- .min(0)
- .error((errors) => new Error('"foo" requires a positive number')),
+ foo: Joi.number()
+ .min(0)
+ .error((errors) => new Error('"foo" requires a positive number')),
});
schema.validate({ foo: -2 }); // returns new Error('"foo" requires a positive number')
```
```js
const schema = Joi.object({
- foo: Joi.number()
- .min(0)
- .error((errors) => {
- return new Error(
- 'found errors with ' +
- errors
- .map(
- (err) =>
- `${err.local.key}(${err.local.limit}) with value ${err.local.value}`,
- )
- .join(' and '),
- );
- }),
+ foo: Joi.number()
+ .min(0)
+ .error((errors) => {
+ return new Error(
+ 'found errors with ' +
+ errors
+ .map(
+ (err) =>
+ `${err.local.key}(${err.local.limit}) with value ${err.local.value}`,
+ )
+ .join(' and '),
+ );
+ }),
});
schema.validate({ foo: -2 }); // returns new Error('found errors with foo(0) with value -2')
```
@@ -800,7 +800,7 @@ Adds examples to the schema where:
- `example` - adds an example. Note that no validation is performed on the value.
- `options` - optional settings:
- - `override` - if `true`, replaces any existing examples. Defaults to `false`.
+ - `override` - if `true`, replaces any existing examples. Defaults to `false`.
```js
const schema = Joi.string().min(4).example('abcd');
@@ -812,16 +812,16 @@ Adds an external validation rule where:
- `method` - an async or sync function with signature `function(value, helpers)` which can either
return a replacement value, `undefined` to indicate no change, or throw an error, where:
- - `value` - a clone of the object containing the value being validated.
- - `helpers` - an object with the following helpers:
- - `schema` - the current schema.
- - `linked` - if the schema is a link, the schema it links to.
- - `state` - the current validation state.
- - `prefs` - the current preferences.
- - `original` - the original value passed into validation before any conversions.
- - `error(code, [local])` - a method to generate error codes using a message code and optional local context.
- - `message(messages, [local])` - a method to generate an error with an internal `'external'` error code and the provided messages object to use as override. Note that this is much slower than using the preferences `messages` option but is much simpler to write when performance is not important.
- - `warn(code, [local])` - a method to add a warning using a message code and optional local context.
+ - `value` - a clone of the object containing the value being validated.
+ - `helpers` - an object with the following helpers:
+ - `schema` - the current schema.
+ - `linked` - if the schema is a link, the schema it links to.
+ - `state` - the current validation state.
+ - `prefs` - the current preferences.
+ - `original` - the original value passed into validation before any conversions.
+ - `error(code, [local])` - a method to generate error codes using a message code and optional local context.
+ - `message(messages, [local])` - a method to generate an error with an internal `'external'` error code and the provided messages object to use as override. Note that this is much slower than using the preferences `messages` option but is much simpler to write when performance is not important.
+ - `warn(code, [local])` - a method to add a warning using a message code and optional local context.
- `description` - optional string used to document the purpose of the method.
Note that external validation rules are only called after the all other validation rules for the
@@ -870,7 +870,7 @@ Marks a key as forbidden which will not allow any value except `undefined`. Used
```js
const schema = {
- a: Joi.any().forbidden(),
+ a: Joi.any().forbidden(),
};
```
@@ -904,8 +904,8 @@ Disallows values where:
```js
const schema = {
- a: Joi.any().invalid('a'),
- b: Joi.any().invalid('b', 'B'),
+ a: Joi.any().invalid('a'),
+ b: Joi.any().invalid('b', 'B'),
};
```
@@ -926,7 +926,7 @@ Overrides the key name in error messages.
```js
const schema = {
- first_name: Joi.string().label('First Name'),
+ first_name: Joi.string().label('First Name'),
};
```
@@ -1035,9 +1035,9 @@ Set the result mode where:
Applies a set of rule options to the current ruleset or last rule added where:
- `options` - the rules to apply where:
- - `keep` - if `true`, the rules will not be replaced by the same unique rule later. For example, `Joi.number().min(1).rule({ keep: true }).min(2)` will keep both `min()` rules instead of the later rule overriding the first. Defaults to `false`.
- - `message` - a single message string or a messages object where each key is an error code and corresponding message string as value. The object is the same as the `messages` used as an option in [`any.validate()`](#anyvalidatevalue-options). The strings can be plain messages or a message template.
- - `warn` - if `true`, turns any error generated by the ruleset to warnings.
+ - `keep` - if `true`, the rules will not be replaced by the same unique rule later. For example, `Joi.number().min(1).rule({ keep: true }).min(2)` will keep both `min()` rules instead of the later rule overriding the first. Defaults to `false`.
+ - `message` - a single message string or a messages object where each key is an error code and corresponding message string as value. The object is the same as the `messages` used as an option in [`any.validate()`](#anyvalidatevalue-options). The strings can be plain messages or a message template.
+ - `warn` - if `true`, turns any error generated by the ruleset to warnings.
When applying rule options, the last rule (e.g. `min()`) is used unless there is an active ruleset defined (e.g. `$.min().max()`) in which case the options are applied to all the provided rules. Once `rule()` is called, the previous rules can no longer be modified and any active ruleset is terminated.
@@ -1050,16 +1050,16 @@ Starts a ruleset in order to apply multiple [rule options](#anyruleoptions). The
```js
const schema = Joi.number()
- .ruleset.min(1)
- .max(10)
- .rule({ message: 'Number must be between 1 and 10' });
+ .ruleset.min(1)
+ .max(10)
+ .rule({ message: 'Number must be between 1 and 10' });
```
```js
const schema = Joi.number()
- .$.min(1)
- .max(10)
- .rule({ message: 'Number must be between 1 and 10' });
+ .$.min(1)
+ .max(10)
+ .rule({ message: 'Number must be between 1 and 10' });
```
#### `any.shared(schema)`
@@ -1070,11 +1070,11 @@ Registers a schema to be used by descendants of the current schema in named link
```js
const schema = Joi.object({
- a: [Joi.string(), Joi.link('#x')],
- b: Joi.link('#type.a'),
+ a: [Joi.string(), Joi.link('#x')],
+ b: Joi.link('#type.a'),
})
- .shared(Joi.number().id('x'))
- .id('type');
+ .shared(Joi.number().id('x'))
+ .id('type');
```
#### `any.strict(isStrict)`
@@ -1097,8 +1097,8 @@ where:
```js
const schema = Joi.object({
- username: Joi.string(),
- password: Joi.string().strip(),
+ username: Joi.string(),
+ password: Joi.string().strip(),
});
schema.validate({ username: 'test', password: 'hunter2' }); // result.value = { username: 'test' }
@@ -1127,10 +1127,10 @@ Applies any assigned target alterations to a copy of the schema that were applie
```js
const schema = Joi.object({
- key: Joi.string().alter({
- get: (schema) => schema.required(),
- post: (schema) => schema.forbidden(),
- }),
+ key: Joi.string().alter({
+ get: (schema) => schema.required(),
+ post: (schema) => schema.forbidden(),
+ }),
});
const getSchema = schema.tailor('get');
@@ -1155,8 +1155,8 @@ Adds the provided values into the allowed values list and marks them as the only
```js
const schema = {
- a: Joi.any().valid('a'),
- b: Joi.any().valid('b', 'B'),
+ a: Joi.any().valid('a'),
+ b: Joi.any().valid('b', 'B'),
};
```
@@ -1168,43 +1168,43 @@ Validates a value using the current schema and options where:
- `value` - the value being validated.
- `options` - an optional object with the following optional keys:
- - `abortEarly` - when `true`, stops validation on the first error, otherwise returns all the errors found. Defaults to `true`.
- - `allowUnknown` - when `true`, allows object to contain unknown keys which are ignored. Defaults to `false`.
- - `cache` - when `true`, schema caching is enabled (for schemas with explicit caching rules). Default to `true`.
- - `context` - provides an external data set to be used in [references](#refkey-options). Can only be set as an external option to `validate()` and not using `any.prefs()`.
- - `convert` - when `true`, attempts to cast values to the required types (e.g. a string to a number). Defaults to `true`.
- - `dateFormat` - sets the string format used when converting dates to strings in error messages and casting. Options are:
- - `'date'` - date string.
- - `'iso'` - date time ISO string. This is the default.
- - `'string'` - JS default date time string.
- - `'time'` - time string.
- - `'utc'` - UTC date time string.
- - `debug` - when `true`, valid results and throw errors are decorated with a `debug` property which includes an array of the validation steps used to generate the returned result. Defaults to `false`.
- - `errors` - error formatting settings:
- - `escapeHtml` - when `true`, error message templates will escape special characters to HTML entities, for security purposes. Defaults to `false`.
- - `label` - defines the value used to set the `label` context variable:
- - `'path'` - the full path to the value being validated. This is the default value.
- - `'key'` - the key of the value being validated.
- - `false` - remove any label prefix from error message, including the `""`.
- - `language` - the preferred language code for error messages. The value is matched against keys at the root of the `messages` object, and then the error code as a child key of that. Can be a reference to the value, global context, or local context which is the root value passed to the validation function. Note that references to the value are usually not what you want as they move around the value structure relative to where the error happens. Instead, either use the global context, or the absolute value (e.g. `Joi.ref('/variable')`);
- - `render` - when `false`, skips rendering error templates. Useful when error messages are generated elsewhere to save processing time. Defaults to `true`.
- - `stack` - when `true`, the main error will possess a stack trace, otherwise it will be disabled. Defaults to `false` for performance reasons. Has no effect on platforms other than V8/node.js as it uses the [Stack trace API](https://v8.dev/docs/stack-trace-api).
- - `wrap` - overrides the way values are wrapped (e.g. `[]` around arrays, `""` around labels and variables prefixed with `:`). Each key can be set to a string with one (same character before and after the value) or two characters (first character before and second character after), or `false` to disable wrapping:
- - `label` - the characters used around `{#label}` references. Defaults to `'"'`.
- - `array` - the characters used around array values. Defaults to `'[]'`.
- - `string` - the characters used around each array string values. Defaults to `false`.
- - `wrapArrays` - if `true`, array values in error messages are wrapped in `[]`. Defaults to `true`.
- - `externals` - if `false`, the external rules set with [`any.external()`](#anyexternalmethod-description) are ignored, which is required to ignore any external validations in synchronous mode (or an exception is thrown). Defaults to `true`.
- - `messages` - overrides individual error messages. Defaults to no override (`{}`). Use the `'*'` error code as a catch-all for all error codes that do not have a message provided in the override. Messages use the same rules as [templates](#template-syntax). Variables in double braces `{{var}}` are HTML escaped if the option `errors.escapeHtml` is set to `true`.
- - `noDefaults` - when `true`, do not apply default values. Defaults to `false`.
- - `nonEnumerables` - when `true`, inputs are shallow cloned to include non-enumerable properties. Defaults to `false`.
- - `presence` - sets the default presence requirements. Supported modes: `'optional'`, `'required'`, and `'forbidden'`. Defaults to `'optional'`.
- - `skipFunctions` - when `true`, ignores unknown keys with a function value. Defaults to `false`.
- - `stripUnknown` - remove unknown elements from objects and arrays. Defaults to `false`.
- - when an `object` :
- - `arrays` - set to `true` to remove unknown items from arrays.
- - `objects` - set to `true` to remove unknown keys from objects.
- - when `true`, it is equivalent to having `{ arrays: false, objects: true }`.
+ - `abortEarly` - when `true`, stops validation on the first error, otherwise returns all the errors found. Defaults to `true`.
+ - `allowUnknown` - when `true`, allows object to contain unknown keys which are ignored. Defaults to `false`.
+ - `cache` - when `true`, schema caching is enabled (for schemas with explicit caching rules). Default to `true`.
+ - `context` - provides an external data set to be used in [references](#refkey-options). Can only be set as an external option to `validate()` and not using `any.prefs()`.
+ - `convert` - when `true`, attempts to cast values to the required types (e.g. a string to a number). Defaults to `true`.
+ - `dateFormat` - sets the string format used when converting dates to strings in error messages and casting. Options are:
+ - `'date'` - date string.
+ - `'iso'` - date time ISO string. This is the default.
+ - `'string'` - JS default date time string.
+ - `'time'` - time string.
+ - `'utc'` - UTC date time string.
+ - `debug` - when `true`, valid results and throw errors are decorated with a `debug` property which includes an array of the validation steps used to generate the returned result. Defaults to `false`.
+ - `errors` - error formatting settings:
+ - `escapeHtml` - when `true`, error message templates will escape special characters to HTML entities, for security purposes. Defaults to `false`.
+ - `label` - defines the value used to set the `label` context variable:
+ - `'path'` - the full path to the value being validated. This is the default value.
+ - `'key'` - the key of the value being validated.
+ - `false` - remove any label prefix from error message, including the `""`.
+ - `language` - the preferred language code for error messages. The value is matched against keys at the root of the `messages` object, and then the error code as a child key of that. Can be a reference to the value, global context, or local context which is the root value passed to the validation function. Note that references to the value are usually not what you want as they move around the value structure relative to where the error happens. Instead, either use the global context, or the absolute value (e.g. `Joi.ref('/variable')`);
+ - `render` - when `false`, skips rendering error templates. Useful when error messages are generated elsewhere to save processing time. Defaults to `true`.
+ - `stack` - when `true`, the main error will possess a stack trace, otherwise it will be disabled. Defaults to `false` for performance reasons. Has no effect on platforms other than V8/node.js as it uses the [Stack trace API](https://v8.dev/docs/stack-trace-api).
+ - `wrap` - overrides the way values are wrapped (e.g. `[]` around arrays, `""` around labels and variables prefixed with `:`). Each key can be set to a string with one (same character before and after the value) or two characters (first character before and second character after), or `false` to disable wrapping:
+ - `label` - the characters used around `{#label}` references. Defaults to `'"'`.
+ - `array` - the characters used around array values. Defaults to `'[]'`.
+ - `string` - the characters used around each array string values. Defaults to `false`.
+ - `wrapArrays` - if `true`, array values in error messages are wrapped in `[]`. Defaults to `true`.
+ - `externals` - if `false`, the external rules set with [`any.external()`](#anyexternalmethod-description) are ignored, which is required to ignore any external validations in synchronous mode (or an exception is thrown). Defaults to `true`.
+ - `messages` - overrides individual error messages. Defaults to no override (`{}`). Use the `'*'` error code as a catch-all for all error codes that do not have a message provided in the override. Messages use the same rules as [templates](#template-syntax). Variables in double braces `{{var}}` are HTML escaped if the option `errors.escapeHtml` is set to `true`.
+ - `noDefaults` - when `true`, do not apply default values. Defaults to `false`.
+ - `nonEnumerables` - when `true`, inputs are shallow cloned to include non-enumerable properties. Defaults to `false`.
+ - `presence` - sets the default presence requirements. Supported modes: `'optional'`, `'required'`, and `'forbidden'`. Defaults to `'optional'`.
+ - `skipFunctions` - when `true`, ignores unknown keys with a function value. Defaults to `false`.
+ - `stripUnknown` - remove unknown elements from objects and arrays. Defaults to `false`.
+ - when an `object` :
+ - `arrays` - set to `true` to remove unknown items from arrays.
+ - `objects` - set to `true` to remove unknown keys from objects.
+ - when `true`, it is equivalent to having `{ arrays: false, objects: true }`.
Returns an object with the following keys:
@@ -1215,11 +1215,11 @@ Returns an object with the following keys:
```js
const schema = Joi.object({
- a: Joi.number(),
+ a: Joi.number(),
});
const value = {
- a: '123',
+ a: '123',
};
const result = schema.validate(value);
@@ -1232,23 +1232,23 @@ Validates a value asynchronously using the current schema and options where:
- `value` - the value being validated.
- `options` - an optional object as described in [`any.validate()`](#anyvalidatevalue-options), with the following additional settings:
- - `artifacts` - when `true`, artifacts are returned alongside the value (i.e. `{ value, artifacts }`). Defaults to `false`.
- - `warnings` - when `true`, warnings are returned alongside the value (i.e. `{ value, warning }`). Defaults to `false`.
+ - `artifacts` - when `true`, artifacts are returned alongside the value (i.e. `{ value, artifacts }`). Defaults to `false`.
+ - `warnings` - when `true`, warnings are returned alongside the value (i.e. `{ value, warning }`). Defaults to `false`.
Returns a Promise that resolves into the validated value when the value is valid. If the value is valid and the `warnings` or `debug` options are set to `true`, returns an object `{ value, warning, debug }`. If validation fails, the promise rejects with the validation error.
```js
const schema = Joi.object({
- a: Joi.number(),
+ a: Joi.number(),
});
const value = {
- a: '123',
+ a: '123',
};
try {
- const value = await schema.validateAsync(value);
- // value -> { "a" : 123 }
+ const value = await schema.validateAsync(value);
+ // value -> { "a" : 123 }
} catch (err) {}
```
@@ -1269,8 +1269,8 @@ When calling [`any.validateAsync()`](#anyvalidateasyncvalue-options), set the `w
```js
const schema = Joi.any()
- .warning('custom.x', { w: 'world' })
- .message({ 'custom.x': 'hello {#w}!' });
+ .warning('custom.x', { w: 'world' })
+ .message({ 'custom.x': 'hello {#w}!' });
const { value, error, warning } = schema.validate('anything');
@@ -1281,11 +1281,11 @@ const { value, error, warning } = schema.validate('anything');
// or
try {
- const { value, warning } = await schema.validateAsync('anything', {
- warnings: true,
- });
- // value -> 'anything';
- // warning -> { message: 'hello world!', details: [...] }
+ const { value, warning } = await schema.validateAsync('anything', {
+ warnings: true,
+ });
+ // value -> 'anything';
+ // warning -> { message: 'hello world!', details: [...] }
} catch (err) {}
```
@@ -1295,12 +1295,12 @@ Adds conditions that are evaluated during validation and modify the schema befor
- `condition` - a key name, [reference](#refkey-options), or a schema. If omitted, defaults to `Joi.ref('.')`.
- `options` - an object with:
- - `is` - the condition expressed as a **joi** schema. Anything that is not a **joi** schema will be converted using [Joi.compile](#compileschema-options). By default, the `is` condition schema allows for `undefined` values. Use `.required()` to override. For example, use `is: Joi.number().required()` to guarantee that a **joi** reference exists and is a number.
- - `not` - the negative version of `is` (`then` and `otherwise` have reverse roles).
- - `then` - if the condition is true, the **joi** schema to use.
- - `otherwise` - if the condition is false, the **joi** schema to use.
- - `switch` - an array of `{ is, then }` conditions that are evaluated against the `condition`. The last item in the array may also contain `otherwise`.
- - `break` - stops processing all other conditions if the rule results in a `then`, `otherwise`, of `switch` match.
+ - `is` - the condition expressed as a **joi** schema. Anything that is not a **joi** schema will be converted using [Joi.compile](#compileschema-options). By default, the `is` condition schema allows for `undefined` values. Use `.required()` to override. For example, use `is: Joi.number().required()` to guarantee that a **joi** reference exists and is a number.
+ - `not` - the negative version of `is` (`then` and `otherwise` have reverse roles).
+ - `then` - if the condition is true, the **joi** schema to use.
+ - `otherwise` - if the condition is false, the **joi** schema to use.
+ - `switch` - an array of `{ is, then }` conditions that are evaluated against the `condition`. The last item in the array may also contain `otherwise`.
+ - `break` - stops processing all other conditions if the rule results in a `then`, `otherwise`, of `switch` match.
If `condition` is a reference:
@@ -1324,16 +1324,16 @@ Notes:
```js
const schema = {
- a: Joi.any()
- .valid('x')
- .when('b', {
- is: Joi.exist(),
- then: Joi.valid('y'),
- otherwise: Joi.valid('z'),
- })
- .when('c', { is: Joi.number().min(10), then: Joi.forbidden() }),
- b: Joi.any(),
- c: Joi.number(),
+ a: Joi.any()
+ .valid('x')
+ .when('b', {
+ is: Joi.exist(),
+ then: Joi.valid('y'),
+ otherwise: Joi.valid('z'),
+ })
+ .when('c', { is: Joi.number().min(10), then: Joi.forbidden() }),
+ b: Joi.any(),
+ c: Joi.number(),
};
```
@@ -1341,15 +1341,15 @@ Or with a schema:
```js
const schema = Joi.object({
- a: Joi.any().valid('x'),
- b: Joi.any(),
+ a: Joi.any().valid('x'),
+ b: Joi.any(),
}).when(Joi.object({ b: Joi.exist() }).unknown(), {
- then: Joi.object({
- a: Joi.valid('y'),
- }),
- otherwise: Joi.object({
- a: Joi.valid('z'),
- }),
+ then: Joi.object({
+ a: Joi.valid('y'),
+ }),
+ otherwise: Joi.object({
+ a: Joi.valid('z'),
+ }),
});
```
@@ -1359,16 +1359,16 @@ validate this logic:
```js
const schema = Joi.object({
- type: Joi.string().valid('A', 'B', 'C').required(), // required if type == 'A'
+ type: Joi.string().valid('A', 'B', 'C').required(), // required if type == 'A'
- foo: Joi.when('type', {
- is: 'A',
- then: Joi.string().valid('X', 'Y', 'Z').required(),
- }), // required if type === 'A' and foo !== 'Z'
+ foo: Joi.when('type', {
+ is: 'A',
+ then: Joi.string().valid('X', 'Y', 'Z').required(),
+ }), // required if type === 'A' and foo !== 'Z'
- bar: Joi.string(),
+ bar: Joi.string(),
}).when(Joi.object({ type: Joi.valid('A'), foo: Joi.not('Z') }).unknown(), {
- then: Joi.object({ bar: Joi.required() }),
+ then: Joi.object({ bar: Joi.required() }),
});
```
@@ -1377,8 +1377,8 @@ like this:
```js
const schema = {
- a: Joi.valid('a', 'b', 'other'),
- other: Joi.string().when('a', { is: 'other', then: Joi.required() }),
+ a: Joi.valid('a', 'b', 'other'),
+ other: Joi.string().when('a', { is: 'other', then: Joi.required() }),
};
```
@@ -1387,17 +1387,17 @@ so like this:
```js
const schema = Joi.object({
- a: Joi.boolean().required(),
- b: Joi.object()
- .keys({
- c: Joi.string(),
- d: Joi.number().required(),
- })
- .required()
- .when('a', {
- is: true,
- then: Joi.object({ c: Joi.required() }), // b.c is required only when a is true
- }),
+ a: Joi.boolean().required(),
+ b: Joi.object()
+ .keys({
+ c: Joi.string(),
+ d: Joi.number().required(),
+ })
+ .required()
+ .when('a', {
+ is: true,
+ then: Joi.object({ c: Joi.required() }), // b.c is required only when a is true
+ }),
});
```
@@ -1406,11 +1406,11 @@ following (notice the use of `required()`):
```js
const schema = Joi.object({
- min: Joi.number(),
- max: Joi.number().when('min', {
- is: Joi.number().required(),
- then: Joi.number().greater(Joi.ref('min')),
- }),
+ min: Joi.number(),
+ max: Joi.number().when('min', {
+ is: Joi.number().required(),
+ then: Joi.number().greater(Joi.ref('min')),
+ }),
});
```
@@ -1418,15 +1418,15 @@ To evaluate multiple values on a single reference:
```js
const schema = Joi.object({
- a: Joi.number().required(),
- b: Joi.number().when('a', {
- switch: [
- { is: 0, then: Joi.valid(1) },
- { is: 1, then: Joi.valid(2) },
- { is: 2, then: Joi.valid(3) },
- ],
- otherwise: Joi.valid(4),
- }),
+ a: Joi.number().required(),
+ b: Joi.number().when('a', {
+ switch: [
+ { is: 0, then: Joi.valid(1) },
+ { is: 1, then: Joi.valid(2) },
+ { is: 2, then: Joi.valid(3) },
+ ],
+ otherwise: Joi.valid(4),
+ }),
});
```
@@ -1434,12 +1434,12 @@ Or shorter:
```js
const schema = Joi.object({
- a: Joi.number().required(),
- b: Joi.number().when('a', [
- { is: 0, then: 1 },
- { is: 1, then: 2 },
- { is: 2, then: 3, otherwise: 4 },
- ]),
+ a: Joi.number().required(),
+ b: Joi.number().when('a', [
+ { is: 0, then: 1 },
+ { is: 1, then: 2 },
+ { is: 2, then: 3, otherwise: 4 },
+ ]),
});
```
@@ -1467,11 +1467,11 @@ Adds a conditional alternative schema type, either based on another key value, o
- `condition` - the key name or [reference](#refkey-options), or a schema.
- `options` - an object with:
- - `is` - the condition expressed as a **joi** schema. Anything that is not a **joi** schema will be converted using [Joi.compile](#compileschema-options).
- - `not` - the negative version of `is` (`then` and `otherwise` have reverse roles).
- - `then` - if the condition is true, the **joi** schema to use.
- - `otherwise` - if the condition is false, the **joi** schema to use.
- - `switch` - an array of `{ is, then }` conditions that are evaluated against the `condition`. The last item in the array may also contain `otherwise`.
+ - `is` - the condition expressed as a **joi** schema. Anything that is not a **joi** schema will be converted using [Joi.compile](#compileschema-options).
+ - `not` - the negative version of `is` (`then` and `otherwise` have reverse roles).
+ - `then` - if the condition is true, the **joi** schema to use.
+ - `otherwise` - if the condition is false, the **joi** schema to use.
+ - `switch` - an array of `{ is, then }` conditions that are evaluated against the `condition`. The last item in the array may also contain `otherwise`.
If `condition` is a reference:
@@ -1492,25 +1492,25 @@ Note that `alternatives.conditional()` is different than `any.when()`. When you
```js
const schema = {
- a: Joi.alternatives().conditional('b', {
- is: 5,
- then: Joi.string(),
- otherwise: Joi.number(),
- }),
- b: Joi.any(),
+ a: Joi.alternatives().conditional('b', {
+ is: 5,
+ then: Joi.string(),
+ otherwise: Joi.number(),
+ }),
+ b: Joi.any(),
};
```
```js
const schema = Joi.alternatives().conditional(Joi.object({ b: 5 }).unknown(), {
- then: Joi.object({
- a: Joi.string(),
- b: Joi.any(),
- }),
- otherwise: Joi.object({
- a: Joi.number(),
- b: Joi.any(),
- }),
+ then: Joi.object({
+ a: Joi.string(),
+ b: Joi.any(),
+ }),
+ otherwise: Joi.object({
+ a: Joi.number(),
+ b: Joi.any(),
+ }),
});
```
@@ -1520,8 +1520,8 @@ this definition of `a`:
```js
const schema = {
- a: Joi.alternatives().conditional('b', { is: true, then: Joi.required() }),
- b: Joi.boolean(),
+ a: Joi.alternatives().conditional('b', { is: true, then: Joi.required() }),
+ b: Joi.boolean(),
};
```
@@ -1534,8 +1534,8 @@ To accomplish the desired result above use:
```js
const schema = {
- a: Joi.when('b', { is: true, then: Joi.required() }),
- b: Joi.boolean(),
+ a: Joi.when('b', { is: true, then: Joi.required() }),
+ b: Joi.boolean(),
};
```
@@ -1544,9 +1544,9 @@ const schema = {
Requires the validated value to match a specific set of the provided `alternative.try()` schemas where:
- `mode` - the match mode which can be one of:
- - `'any'` - match any provided schema. This is the default value.
- - `'all'` - match all of the provided schemas. Note that this will ignore any conversions performed by the matchin schemas and return the raw value provided regardless of the `convert` preference set.
- - `'one'` - match one and only one of the provided schemas.
+ - `'any'` - match any provided schema. This is the default value.
+ - `'all'` - match all of the provided schemas. Note that this will ignore any conversions performed by the matchin schemas and return the raw value provided regardless of the `convert` preference set.
+ - `'one'` - match one and only one of the provided schemas.
Note: Cannot be combined with `alternatives.conditional()`.
@@ -1586,13 +1586,13 @@ Verifies that a schema validates at least one of the values in the array, where:
```js
const schema = Joi.array()
- .items(
- Joi.object({
- a: Joi.string(),
- b: Joi.number(),
- }),
- )
- .has(Joi.object({ a: Joi.string().valid('a'), b: Joi.number() }));
+ .items(
+ Joi.object({
+ a: Joi.string(),
+ b: Joi.number(),
+ }),
+ )
+ .has(Joi.object({ a: Joi.string().valid('a'), b: Joi.number() }));
```
Possible validation errors: [`array.hasKnown`](#arrayhasknown), [`array.hasUnknown`](#arrayhasunknown)
@@ -1611,16 +1611,16 @@ Errors will contain the number of items that didn't match. Any unmatched item ha
```js
const schema = Joi.array().items(Joi.string(), Joi.number()); // array may contain strings and numbers
const schema = Joi.array().items(
- Joi.string().required(),
- Joi.string().required(),
+ Joi.string().required(),
+ Joi.string().required(),
); // array must contain at least two strings
const schema = Joi.array().items(
- Joi.string().valid('not allowed').forbidden(),
- Joi.string(),
+ Joi.string().valid('not allowed').forbidden(),
+ Joi.string(),
); // array may contain strings, but none of those strings can match 'not allowed'
const schema = Joi.array().items(
- Joi.string().label('My string').required(),
- Joi.number().required(),
+ Joi.string().label('My string').required(),
+ Joi.number().required(),
); // If this fails it can result in `[ValidationError: "value" does not contain [My string] and 1 other required value(s)]`
```
@@ -1638,8 +1638,8 @@ const schema = Joi.array().length(5);
```js
const schema = Joi.object({
- limit: Joi.number().integer().required(),
- numbers: Joi.array().length(Joi.ref('limit')).required(),
+ limit: Joi.number().integer().required(),
+ numbers: Joi.array().length(Joi.ref('limit')).required(),
});
```
@@ -1657,8 +1657,8 @@ const schema = Joi.array().max(10);
```js
const schema = Joi.object({
- limit: Joi.number().integer().required(),
- numbers: Joi.array().max(Joi.ref('limit')).required(),
+ limit: Joi.number().integer().required(),
+ numbers: Joi.array().max(Joi.ref('limit')).required(),
});
```
@@ -1676,8 +1676,8 @@ const schema = Joi.array().min(2);
```js
const schema = Joi.object({
- limit: Joi.number().integer().required(),
- numbers: Joi.array().min(Joi.ref('limit')).required(),
+ limit: Joi.number().integer().required(),
+ numbers: Joi.array().min(Joi.ref('limit')).required(),
});
```
@@ -1694,12 +1694,12 @@ Errors will contain the number of items that didn't match. Any unmatched item ha
```js
const schema = Joi.array().ordered(
- Joi.string().required(),
- Joi.number().required(),
+ Joi.string().required(),
+ Joi.number().required(),
); // array must have first item as string and second item as number
const schema = Joi.array()
- .ordered(Joi.string().required())
- .items(Joi.number().required()); // array must have first item as string and 1 or more subsequent items as number
+ .ordered(Joi.string().required())
+ .items(Joi.number().required()); // array must have first item as string and 1 or more subsequent items as number
const schema = Joi.array().ordered(Joi.string().required(), Joi.number()); // array must have first item as string and optionally second item as number
```
@@ -1724,10 +1724,10 @@ Possible validation errors: [`array.excludes`](#arrayexcludes), [`array.includes
Requires the array to comply with the specified sort order where:
- `options` - optional settings:
- - `order` - the sort order. Allowed values:
- - `'ascending'` - sort the array in ascending order. This is the default.
- - `'descending'` - sort the array in descending order.
- - `by` - a key name or reference to sort array objects by. Defaults to the entire value.
+ - `order` - the sort order. Allowed values:
+ - `'ascending'` - sort the array in ascending order. This is the default.
+ - `'descending'` - sort the array in descending order.
+ - `by` - a key name or reference to sort array objects by. Defaults to the entire value.
Notes:
@@ -1753,16 +1753,16 @@ Possible validation errors: [`array.sparse`](#arraysparse)
Requires the array values to be unique where:
- `comparator` - an optional custom `comparator` that is either:
- - a function that takes 2 parameters to compare. This function should return whether the 2
- parameters are equal or not, you are also **responsible** for this function not to fail, any
- `Error` would bubble out of Joi.
- - a string in dot notation representing the path of the element to do uniqueness check on. Any
- missing path will be considered undefined, and can as well only exist once.
+ - a function that takes 2 parameters to compare. This function should return whether the 2
+ parameters are equal or not, you are also **responsible** for this function not to fail, any
+ `Error` would bubble out of Joi.
+ - a string in dot notation representing the path of the element to do uniqueness check on. Any
+ missing path will be considered undefined, and can as well only exist once.
- `options` - optional settings:
- - `ignoreUndefined` - if `true`, undefined values for the dot notation string comparator will
- not cause the array to fail on uniqueness. Defaults to `false`.
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the
- `key` as a literal value.
+ - `ignoreUndefined` - if `true`, undefined values for the dot notation string comparator will
+ not cause the array to fail on uniqueness. Defaults to `false`.
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the
+ `key` as a literal value.
Note: remember that if you provide a custom comparator function, different types can be passed as parameter depending on the rules you set on items.
@@ -1936,8 +1936,8 @@ const schema = Joi.date().greater('now');
```js
const schema = Joi.object({
- from: Joi.date().required(),
- to: Joi.date().greater(Joi.ref('from')).required(),
+ from: Joi.date().required(),
+ to: Joi.date().greater(Joi.ref('from')).required(),
});
```
@@ -1969,8 +1969,8 @@ const schema = Joi.date().less('now');
```js
const schema = Joi.object({
- from: Joi.date().less(Joi.ref('to')).required(),
- to: Joi.date().required(),
+ from: Joi.date().less(Joi.ref('to')).required(),
+ to: Joi.date().required(),
});
```
@@ -1994,8 +1994,8 @@ const schema = Joi.date().max('now');
```js
const schema = Joi.object({
- from: Joi.date().max(Joi.ref('to')).required(),
- to: Joi.date().required(),
+ from: Joi.date().max(Joi.ref('to')).required(),
+ to: Joi.date().required(),
});
```
@@ -2019,8 +2019,8 @@ const schema = Joi.date().min('now');
```js
const schema = Joi.object({
- from: Joi.date().required(),
- to: Joi.date().min(Joi.ref('from')).required(),
+ from: Joi.date().required(),
+ to: Joi.date().min(Joi.ref('from')).required(),
});
```
@@ -2117,13 +2117,17 @@ Note that named links must be found in a direct ancestor of the link. The names
Links are resolved once (per runtime) and the result schema cached. If you reuse a link in different places, the first time it is resolved at run-time, the result will be used by all other instances. If you want each link to resolve relative to the place it is used, use a separate `Joi.link()` statement in each place or set the `relative()` flag.
+As a safety net, when validation exceeds the runtime call stack while resolving a link, validation fails with the `link.depth` error code instead of crashing the process.
+
+Possible validation errors: [`link.depth`](#linkdepth)
+
Named links:
```js
const person = Joi.object({
- firstName: Joi.string().required(),
- lastName: Joi.string().required(),
- children: Joi.array().items(Joi.link('#person')),
+ firstName: Joi.string().required(),
+ lastName: Joi.string().required(),
+ children: Joi.array().items(Joi.link('#person')),
}).id('person');
```
@@ -2131,12 +2135,12 @@ Relative links:
```js
const person = Joi.object({
- firstName: Joi.string().required(),
- lastName: Joi.string().required(),
- children: Joi.array().items(Joi.link('...')),
- // . - the link
- // .. - the children array
- // ... - the person object
+ firstName: Joi.string().required(),
+ lastName: Joi.string().required(),
+ children: Joi.array().items(Joi.link('...')),
+ // . - the link
+ // .. - the children array
+ // ... - the person object
});
```
@@ -2144,9 +2148,9 @@ Absolute links:
```js
const person = Joi.object({
- firstName: Joi.string().required(),
- lastName: Joi.string().required(),
- children: Joi.array().items(Joi.link('/')),
+ firstName: Joi.string().required(),
+ lastName: Joi.string().required(),
+ children: Joi.array().items(Joi.link('/')),
});
```
@@ -2159,8 +2163,8 @@ Will throw an error during validation if left uninitialized (e.g. `Joi.link()` c
```js
const schema = Joi.object({
- a: [Joi.string(), Joi.number()],
- b: Joi.link().ref('#type.a'),
+ a: [Joi.string(), Joi.number()],
+ b: Joi.link().ref('#type.a'),
}).id('type');
```
@@ -2198,8 +2202,8 @@ const schema = Joi.number().greater(5);
```js
const schema = Joi.object({
- min: Joi.number().required(),
- max: Joi.number().greater(Joi.ref('min')).required(),
+ min: Joi.number().required(),
+ max: Joi.number().greater(Joi.ref('min')).required(),
});
```
@@ -2225,8 +2229,8 @@ const schema = Joi.number().less(10);
```js
const schema = Joi.object({
- min: Joi.number().less(Joi.ref('max')).required(),
- max: Joi.number().required(),
+ min: Joi.number().less(Joi.ref('max')).required(),
+ max: Joi.number().required(),
});
```
@@ -2244,8 +2248,8 @@ const schema = Joi.number().max(10);
```js
const schema = Joi.object({
- min: Joi.number().max(Joi.ref('max')).required(),
- max: Joi.number().required(),
+ min: Joi.number().max(Joi.ref('max')).required(),
+ max: Joi.number().required(),
});
```
@@ -2263,8 +2267,8 @@ const schema = Joi.number().min(2);
```js
const schema = Joi.object({
- min: Joi.number().required(),
- max: Joi.number().min(Joi.ref('min')).required(),
+ min: Joi.number().required(),
+ max: Joi.number().min(Joi.ref('min')).required(),
});
```
@@ -2361,8 +2365,8 @@ Supports the same methods of the [`any()`](#any) type.
```js
const object = Joi.object({
- a: Joi.number().min(1).max(10).integer(),
- b: 'some string',
+ a: Joi.number().min(1).max(10).integer(),
+ b: 'some string',
});
await object.validateAsync({ a: 5 });
@@ -2384,13 +2388,13 @@ them are required as well where:
- `peers` - the string key names of which if one present, all are required.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).and('a', 'b');
```
@@ -2405,11 +2409,11 @@ Appends the allowed object keys where:
```js
// Validate key a
const base = Joi.object({
- a: Joi.number(),
+ a: Joi.number(),
});
// Validate keys a, b.
const extended = base.append({
- b: Joi.string(),
+ b: Joi.string(),
});
```
@@ -2424,13 +2428,13 @@ Verifies an assertion where:
```js
const schema = Joi.object({
- a: {
- b: Joi.string(),
- c: Joi.number(),
- },
- d: {
- e: Joi.any(),
- },
+ a: {
+ b: Joi.string(),
+ c: Joi.number(),
+ },
+ d: {
+ e: Joi.any(),
+ },
}).assert('.d.e', Joi.ref('a.c'), 'equal to a.c');
```
@@ -2460,12 +2464,12 @@ Sets or extends the allowed object keys where:
```js
const base = Joi.object().keys({
- a: Joi.number(),
- b: Joi.string(),
+ a: Joi.number(),
+ b: Joi.string(),
});
// Validate keys a, b and c.
const extended = base.keys({
- c: Joi.boolean(),
+ c: Joi.boolean(),
});
```
@@ -2513,13 +2517,13 @@ Defines a relationship between keys where not all peers can be present at the sa
- `peers` - the key names of which if one present, the others may not all be present.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).nand('a', 'b');
```
@@ -2532,13 +2536,13 @@ allowed) where:
- `peers` - the key names of which at least one must appear.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).or('a', 'b');
```
@@ -2551,13 +2555,13 @@ required where:
- `peers` - the exclusive key names that must not appear together but where none are required.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).oxor('a', 'b');
```
@@ -2570,20 +2574,20 @@ Specify validation rules for unknown keys matching a pattern where:
- `pattern` - a pattern that can be either a regular expression or a **joi** schema that will be tested against the unknown key names. Note that if the pattern is a regular expression, for it to match the entire key name, it must begin with `^` and end with `$`.
- `schema` - the schema object matching keys must validate against.
- `options` - options settings:
- - `fallthrough` - if `true`, multiple matching patterns are tested against the key, otherwise once a pattern match is found, no other patterns are compared. Defaults to `false`.
- - `matches` - a joi array schema used to validated the array of matching keys. For example, `Joi.object().pattern(/\d/, Joi.boolean(), { matches: Joi.array().length(2) })` will require two matching keys. If the `matches` schema is not an array type schema, it will be converted to `Joi.array().items(matches)`. If the `matches` schema contains references, they are resolved against the ancestors as follows:
- - self - the array of matching keys (`Joi.ref('.length')`)
- - parent - the object value containing the keys (`Joi.ref('a')`)
+ - `fallthrough` - if `true`, multiple matching patterns are tested against the key, otherwise once a pattern match is found, no other patterns are compared. Defaults to `false`.
+ - `matches` - a joi array schema used to validated the array of matching keys. For example, `Joi.object().pattern(/\d/, Joi.boolean(), { matches: Joi.array().length(2) })` will require two matching keys. If the `matches` schema is not an array type schema, it will be converted to `Joi.array().items(matches)`. If the `matches` schema contains references, they are resolved against the ancestors as follows:
+ - self - the array of matching keys (`Joi.ref('.length')`)
+ - parent - the object value containing the keys (`Joi.ref('a')`)
```js
const schema = Joi.object({
- a: Joi.string(),
+ a: Joi.string(),
}).pattern(/\w\d/, Joi.boolean());
// OR
const schema = Joi.object({
- a: Joi.string(),
+ a: Joi.string(),
}).pattern(Joi.string().min(2).max(5), Joi.boolean());
```
@@ -2616,16 +2620,16 @@ Renames a key to another name (deletes the renamed key) where:
- `from` - the original key name or a regular expression matching keys.
- `to` - the new key name. `to` can be set to a [`template`](#templatetemplate-options) which is rendered at runtime using the current value, global context, and local context if `from` is a regular expression (e.g. the expression `/^(\d+)$/` will match any all-digits keys with a capture group that is accessible in the template via `{#1}`).
- `options` - an optional object with the following optional keys:
- - `alias` - if `true`, does not delete the old key name, keeping both the new and old keys in place. Defaults to `false`.
- - `multiple` - if `true`, allows renaming multiple keys to the same destination where the last rename wins. Defaults to `false`.
- - `override` - if `true`, allows renaming a key over an existing key. Defaults to `false`.
- - `ignoreUndefined` - if `true`, skip renaming of a key if it's undefined. Defaults to `false`.
+ - `alias` - if `true`, does not delete the old key name, keeping both the new and old keys in place. Defaults to `false`.
+ - `multiple` - if `true`, allows renaming multiple keys to the same destination where the last rename wins. Defaults to `false`.
+ - `override` - if `true`, allows renaming a key over an existing key. Defaults to `false`.
+ - `ignoreUndefined` - if `true`, skip renaming of a key if it's undefined. Defaults to `false`.
Keys are renamed before any other validation rules are applied. If `to` is a template that references the object own keys (e.g. `'{.prefix}-{#1}'`), the value of these keys is the raw input value, not the value generated after validation. If a key is renamed and then its value fails to pass a validation rule, the error message will use the renamed key, not the original key which may be confusing for users (labels can help in some cases).
```js
const object = Joi.object({
- a: Joi.number(),
+ a: Joi.number(),
}).rename('b', 'a');
await object.validateAsync({ b: 5 });
@@ -2637,7 +2641,7 @@ Using a regular expression:
const regex = /^foobar$/i;
const schema = Joi.object({
- fooBar: Joi.string(),
+ fooBar: Joi.string(),
}).rename(regex, 'fooBar');
await schema.validateAsync({ FooBar: 'a' });
@@ -2647,14 +2651,14 @@ Using a regular expression with template:
```js
const schema = Joi.object()
- .rename(/^(\d+)$/, Joi.expression('x{#1}x'))
- .pattern(/^x\d+x$/, Joi.any());
+ .rename(/^(\d+)$/, Joi.expression('x{#1}x'))
+ .pattern(/^x\d+x$/, Joi.any());
const input = {
- 123: 'x',
- 1: 'y',
- 0: 'z',
- x4x: 'test',
+ 123: 'x',
+ 1: 'y',
+ 0: 'z',
+ x4x: 'test',
};
const value = await Joi.compile(schema).validateAsync(input);
@@ -2695,16 +2699,16 @@ Requires the presence of other keys whenever the specified key is present where:
- `peers` - the required peer key names that must appear together with `key`. `peers` can be a
single string value or an array of string values.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
Note that unlike [`object.and()`](#objectandpeers-options), `with()` creates a dependency only between the `key` and each of the `peers`, not
between the `peers` themselves.
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).with('a', 'b');
```
@@ -2718,13 +2722,13 @@ Forbids the presence of other keys whenever the specified is present where:
- `peers` - the forbidden peer key names that must not appear together with `key`. `peers` can be a
single string value or an array of string values.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).without('a', ['b']);
```
@@ -2737,13 +2741,13 @@ the same time where:
- `peers` - the exclusive key names that must not appear together but where one of them is required.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).xor('a', 'b');
```
@@ -2788,8 +2792,8 @@ Possible validation errors: [`string.alphanum`](#stringalphanum-1)
Requires the string value to be a valid base64 string; does not check the decoded value.
- `options` - optional settings:
- - `paddingRequired` - if `true`, the string must be properly padded with the `=` characters. Defaults to `true`.
- - `urlSafe` - if `true`, uses the URI-safe base64 format which replaces `+` with `-` and `\` with `_`. Defaults to `false`.
+ - `paddingRequired` - if `true`, the string must be properly padded with the `=` characters. Defaults to `true`.
+ - `urlSafe` - if `true`, uses the URI-safe base64 format which replaces `+` with `-` and `\` with `_`. Defaults to `false`.
Padding characters are not required for decoding, as the number of missing bytes can be inferred from the number of digits. With that said, try to use padding if at all possible.
@@ -2837,7 +2841,7 @@ Possible validation errors: [`string.creditCard`](#stringcreditcard-1)
Requires the string value to be a valid data URI string.
- `options` - optional settings:
- - `paddingRequired` - optional parameter defaulting to `true` which will require `=` padding if `true` or make padding optional if `false`.
+ - `paddingRequired` - optional parameter defaulting to `true` which will require `=` padding if `true` or make padding optional if `false`.
```js
const schema = Joi.string().dataUri();
@@ -2852,21 +2856,21 @@ Possible validation errors: [`string.dataUri`](#stringdatauri)
Requires the string value to be a valid domain name.
- `options` - optional settings:
- - `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
- - `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
- - `minDomainSegments` - number of segments required for the domain. Defaults to `2`.
- - `maxDomainSegments` - maximum number of allowed domain segments. Default to no limit.
- - `tlds` - options for TLD (top level domain) validation. By default, the TLD must be a valid
- name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt). To
- disable validation, set `tlds` to `false`. To customize how TLDs are validated, set one of
- these:
- - `allow` - one of:
- - `true` to use the IANA list of registered TLDs. This is the default value.
- - `false` to allow any TLD not listed in the `deny` list, if present.
- - a `Set` or array of the allowed TLDs. Cannot be used together with `deny`.
- - `deny` - one of:
- - a `Set` or array of the forbidden TLDs. Cannot be used together with a custom `allow`
- list.
+ - `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
+ - `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
+ - `minDomainSegments` - number of segments required for the domain. Defaults to `2`.
+ - `maxDomainSegments` - maximum number of allowed domain segments. Default to no limit.
+ - `tlds` - options for TLD (top level domain) validation. By default, the TLD must be a valid
+ name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt). To
+ disable validation, set `tlds` to `false`. To customize how TLDs are validated, set one of
+ these:
+ - `allow` - one of:
+ - `true` to use the IANA list of registered TLDs. This is the default value.
+ - `false` to allow any TLD not listed in the `deny` list, if present.
+ - a `Set` or array of the allowed TLDs. Cannot be used together with `deny`.
+ - `deny` - one of:
+ - a `Set` or array of the forbidden TLDs. Cannot be used together with a custom `allow`
+ list.
```js
const schema = Joi.string().domain();
@@ -2879,28 +2883,28 @@ Possible validation errors: [`string.domain`](#stringdomain)
Requires the string value to be a valid email address.
- `options` - optional settings:
- - `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
- - `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
- - `ignoreLength` - if `true`, ignore invalid email length errors. Defaults to `false`.
- - `minDomainSegments` - number of segments required for the domain. The default setting excludes
- single segment domains such as `example@io` which is a valid email but very uncommon. Defaults
- to `2`.
- - `maxDomainSegments` - maximum number of allowed domain segments. Default to no limit.
- - `multiple` - if `true`, allows multiple email addresses in a single string, separated by `,`
- or the `separator` characters. Defaults to `false`.
- - `separator` - when `multiple` is `true`, overrides the default `,` separator. String can be
- a single character or multiple separator characters. Defaults to `','`.
- - `tlds` - options for TLD (top level domain) validation. By default, the TLD must be a valid
- name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt). To
- disable validation, set `tlds` to `false`. To customize how TLDs are validated, set one of
- these:
- - `allow` - one of:
- - `true` to use the IANA list of registered TLDs. This is the default value.
- - `false` to allow any TLD not listed in the `deny` list, if present.
- - a `Set` or array of the allowed TLDs. Cannot be used together with `deny`.
- - `deny` - one of:
- - a `Set` or array of the forbidden TLDs. Cannot be used together with a custom `allow`
- list.
+ - `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
+ - `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
+ - `ignoreLength` - if `true`, ignore invalid email length errors. Defaults to `false`.
+ - `minDomainSegments` - number of segments required for the domain. The default setting excludes
+ single segment domains such as `example@io` which is a valid email but very uncommon. Defaults
+ to `2`.
+ - `maxDomainSegments` - maximum number of allowed domain segments. Default to no limit.
+ - `multiple` - if `true`, allows multiple email addresses in a single string, separated by `,`
+ or the `separator` characters. Defaults to `false`.
+ - `separator` - when `multiple` is `true`, overrides the default `,` separator. String can be
+ a single character or multiple separator characters. Defaults to `','`.
+ - `tlds` - options for TLD (top level domain) validation. By default, the TLD must be a valid
+ name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt). To
+ disable validation, set `tlds` to `false`. To customize how TLDs are validated, set one of
+ these:
+ - `allow` - one of:
+ - `true` to use the IANA list of registered TLDs. This is the default value.
+ - `false` to allow any TLD not listed in the `deny` list, if present.
+ - a `Set` or array of the allowed TLDs. Cannot be used together with `deny`.
+ - `deny` - one of:
+ - a `Set` or array of the forbidden TLDs. Cannot be used together with a custom `allow`
+ list.
```js
const schema = Joi.string().email();
@@ -2915,19 +2919,19 @@ Possible validation errors: [`string.email`](#stringemail)
Requires the string value to be a valid GUID.
- `options` - optional settings:
- - `version` - specifies one or more acceptable versions. Can be an Array or String with the following values:
- `uuidv1`, `uuidv2`, `uuidv3`, `uuidv4`, `uuidv5`, `uuidv6`, `uuidv7` or `uuidv8`. If no `version` is specified then it is assumed to be a generic `guid`
- which will not validate the version or variant of the guid and just check for general structure format.
- - `separator` - defines the allowed or required GUID separator where:
- - `true` - a separator is required, can be either `:` or `-`.
- - `false` - separator is not allowed.
- - `'-'` - a dash separator is required.
- - `':'` - a colon separator is required.
- - defaults to optional `:` or `-` separator.
+ - `version` - specifies one or more acceptable versions. Can be an Array or String with the following values:
+ `uuidv1`, `uuidv2`, `uuidv3`, `uuidv4`, `uuidv5`, `uuidv6`, `uuidv7` or `uuidv8`. If no `version` is specified then it is assumed to be a generic `guid`
+ which will not validate the version or variant of the guid and just check for general structure format.
+ - `separator` - defines the allowed or required GUID separator where:
+ - `true` - a separator is required, can be either `:` or `-`.
+ - `false` - separator is not allowed.
+ - `'-'` - a dash separator is required.
+ - `':'` - a colon separator is required.
+ - defaults to optional `:` or `-` separator.
```js
const schema = Joi.string().guid({
- version: ['uuidv4', 'uuidv5'],
+ version: ['uuidv4', 'uuidv5'],
});
```
@@ -2938,8 +2942,8 @@ Possible validation errors: [`string.guid`](#stringguid)
Requires the string value to be a valid hexadecimal string.
- `options` - optional settings:
- - `byteAligned` - Boolean specifying whether you want to check that the hexadecimal string is byte aligned. If `convert` is `true`, a `0` will be added in front of the string in case it needs to be aligned. Defaults to `false`.
- - `prefix` - Boolean or `optional`. When `true`, the string will be considered valid if prefixed with `0x` or `0X`. When `false`, the prefix is forbidden. When `optional`, the string will be considered valid if prefixed or not prefixed at all. Defaults to `false`.
+ - `byteAligned` - Boolean specifying whether you want to check that the hexadecimal string is byte aligned. If `convert` is `true`, a `0` will be added in front of the string in case it needs to be aligned. Defaults to `false`.
+ - `prefix` - Boolean or `optional`. When `true`, the string will be considered valid if prefixed with `0x` or `0X`. When `false`, the prefix is forbidden. When `optional`, the string will be considered valid if prefixed or not prefixed at all. Defaults to `false`.
```js
const schema = Joi.string().hex({ prefix: 'optional' });
@@ -2970,14 +2974,14 @@ const schema = Joi.string().valid('a').insensitive();
Requires the string value to be a valid ip address.
- `options` - optional settings:
- - `version` - One or more IP address versions to validate against. Valid values: `ipv4`, `ipv6`, `ipvfuture`
- - `cidr` - Used to determine if a CIDR is allowed or not. Valid values: `optional`, `required`, `forbidden`
+ - `version` - One or more IP address versions to validate against. Valid values: `ipv4`, `ipv6`, `ipvfuture`
+ - `cidr` - Used to determine if a CIDR is allowed or not. Valid values: `optional`, `required`, `forbidden`
```js
// Accept only ipv4 and ipv6 addresses with a CIDR
const schema = Joi.string().ip({
- version: ['ipv4', 'ipv6'],
- cidr: 'required',
+ version: ['ipv4', 'ipv6'],
+ cidr: 'required',
});
```
@@ -3027,8 +3031,8 @@ const schema = Joi.string().length(5);
```js
const schema = Joi.object({
- length: Joi.string().required(),
- value: Joi.string().length(Joi.ref('length'), 'utf8').required(),
+ length: Joi.string().required(),
+ value: Joi.string().length(Joi.ref('length'), 'utf8').required(),
});
```
@@ -3058,8 +3062,8 @@ const schema = Joi.string().max(10);
```js
const schema = Joi.object({
- max: Joi.string().required(),
- value: Joi.string().max(Joi.ref('max'), 'utf8').required(),
+ max: Joi.string().required(),
+ value: Joi.string().max(Joi.ref('max'), 'utf8').required(),
});
```
@@ -3078,8 +3082,8 @@ const schema = Joi.string().min(2);
```js
const schema = Joi.object({
- min: Joi.string().required(),
- value: Joi.string().min(Joi.ref('min'), 'utf8').required(),
+ min: Joi.string().required(),
+ value: Joi.string().min(Joi.ref('min'), 'utf8').required(),
});
```
@@ -3109,9 +3113,9 @@ Defines a pattern rule where:
- `regex` - a regular expression object the string value must match against. Note that if the pattern is a regular expression, for it to match the entire key name, it must begin with `^` and end with `$`.
- `name` - optional name for patterns (useful with multiple patterns).
- `options` - an optional configuration object with the following supported properties:
- - `name` - optional pattern name.
- - `invert` - optional boolean flag. Defaults to `false` behavior. If specified as `true`, the
- provided pattern will be disallowed instead of required.
+ - `name` - optional pattern name.
+ - `invert` - optional boolean flag. Defaults to `false` behavior. If specified as `true`, the
+ provided pattern will be disallowed instead of required.
```js
const schema = Joi.string().pattern(/^[abc]+$/);
@@ -3126,8 +3130,8 @@ const invertedSchema = Joi.string().pattern(/^[a-z]+$/, { invert: true });
invertedSchema.validate('lowercase'); // ValidationError: "value" with value "lowercase" matches the inverted pattern: [a-z]
const invertedNamedSchema = Joi.string().pattern(/^[a-z]+$/, {
- name: 'alpha',
- invert: true,
+ name: 'alpha',
+ invert: true,
});
invertedNamedSchema.validate('lowercase'); // ValidationError: "value" with value "lowercase" matches the inverted alpha pattern
```
@@ -3203,17 +3207,17 @@ Possible validation errors: [`string.uppercase`](#stringuppercase-1)
Requires the string value to be a valid [RFC 3986](http://tools.ietf.org/html/rfc3986) URI.
- `options` - optional settings:
- - `scheme` - Specifies one or more acceptable Schemes, should only include the scheme name. Can be an Array or String (strings are automatically escaped for use in a Regular Expression).
- - `allowRelative` - Allow relative URIs. Defaults to `false`.
- - `relativeOnly` - Restrict only relative URIs. Defaults to `false`.
- - `allowQuerySquareBrackets` - Allows unencoded square brackets inside the query string. This is **NOT** RFC 3986 compliant but query strings like `abc[]=123&abc[]=456` are very common these days. Defaults to `false`.
- - `domain` - Validate the domain component using the options specified in [`string.domain()`](#stringdomainoptions).
- - `encodeUri` - When `convert` is true, if the validation fails, attempts to encode the URI using [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) before validating it again. This allows to provide, for example, unicode URIs, and have it encoded for you. Defaults to `false`.
+ - `scheme` - Specifies one or more acceptable Schemes, should only include the scheme name. Can be an Array or String (strings are automatically escaped for use in a Regular Expression).
+ - `allowRelative` - Allow relative URIs. Defaults to `false`.
+ - `relativeOnly` - Restrict only relative URIs. Defaults to `false`.
+ - `allowQuerySquareBrackets` - Allows unencoded square brackets inside the query string. This is **NOT** RFC 3986 compliant but query strings like `abc[]=123&abc[]=456` are very common these days. Defaults to `false`.
+ - `domain` - Validate the domain component using the options specified in [`string.domain()`](#stringdomainoptions).
+ - `encodeUri` - When `convert` is true, if the validation fails, attempts to encode the URI using [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) before validating it again. This allows to provide, for example, unicode URIs, and have it encoded for you. Defaults to `false`.
```js
// Accept git or git http/https
const schema = Joi.string().uri({
- scheme: ['git', /git\+https?/],
+ scheme: ['git', /git\+https?/],
});
```
@@ -3239,14 +3243,14 @@ Possible validation errors: [`symbol.base`](#symbolbase)
Allows values to be transformed into `Symbol`s, where:
- `map` - mapping declaration that can be:
- - an object, where keys are strings, and values are `Symbol`s
- - an array of arrays of length 2, where for each sub-array, the 1st element must be anything but an object, a function or a `Symbol`, and the 2nd element must be a Symbol
- - a `Map`, following the same principles as the array above
+ - an object, where keys are strings, and values are `Symbol`s
+ - an array of arrays of length 2, where for each sub-array, the 1st element must be anything but an object, a function or a `Symbol`, and the 2nd element must be a Symbol
+ - a `Map`, following the same principles as the array above
```js
const schema = Joi.symbol().map([
- [1, Symbol('one')],
- ['two', Symbol('two')],
+ [1, Symbol('one')],
+ ['two', Symbol('two')],
]);
```
@@ -3280,153 +3284,154 @@ Where:
- `base`: The base schema to extend from. This key is forbidden when `type` is a regular expression.
- `messages`: A hash of error codes and their messages. To interpolate dynamic values, use the [template syntax](#template-syntax).
- `flags`: A hash of flag names and their definitions where:
- - `default`: The default value of the flag. When `describe()` is called and the current flag matches this default value, it will be omitted entirely from the description.
+ - `default`: The default value of the flag. When `describe()` is called and the current flag matches this default value, it will be omitted entirely from the description.
- `prepare`: A function with signature `function (value, helpers) {}` that prepares the input value (for example, converts `,` to `.` to support multiple decimal representations) where:
- - `value`: The input value.
- - `helpers`: [Validation helpers](#validation-helpers)
+ - `value`: The input value.
+ - `helpers`: [Validation helpers](#validation-helpers)
- Must return an object with one of the following keys:
- - `value`: The modified value.
- - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
+ Must return an object with one of the following keys:
+ - `value`: The modified value.
+ - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
- If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
+ If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
- `coerce`: A function with signature `function (value, helpers) {}` that coerces the input value where:
- - `value`: The input value.
- - `helpers`: [Validation helpers](#validation-helpers)
-
- You can also pass an object where:
- - `from`: The type(s) to convert from. Can be a single string or an array of strings. Joi will only run `method` if the value `typeof` of the input value is equal to one of the provided values.
- - `method`: A function with signature `function (value, helpers)` that coerces the input value where:
- `value`: The input value.
- `helpers`: [Validation helpers](#validation-helpers)
- Must return an object with one of the following keys:
- - `value`: The modified value.
- - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
+ You can also pass an object where:
+ - `from`: The type(s) to convert from. Can be a single string or an array of strings. Joi will only run `method` if the value `typeof` of the input value is equal to one of the provided values.
+ - `method`: A function with signature `function (value, helpers)` that coerces the input value where:
+ - `value`: The input value.
+ - `helpers`: [Validation helpers](#validation-helpers)
- If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
+ Must return an object with one of the following keys:
+ - `value`: The modified value.
+ - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
+
+ If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
- `validate`: A function with signature `function (value, helpers) {}` that performs base validation on the input value where:
- - `value`: The input value.
- - `helpers`: [Validation helpers](#validation-helpers)
+ - `value`: The input value.
+ - `helpers`: [Validation helpers](#validation-helpers)
- Must return an object with one of the following keys:
- - `value`: The modified value.
- - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
+ Must return an object with one of the following keys:
+ - `value`: The modified value.
+ - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
- If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
+ If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
- `rules`: A hash of validation rule names and their implementation where:
- - `alias`: Aliases of the rule. Can be a string or an array of strings.
- - `args`: An array of argument names or an object that define the parameters the rule will accept where:
- - `name`: The argument name.
- - `ref`: Whether this argument allows references. Joi will resolve them before passing to `validate`. Defaults to `false`.
- - `assert`: A function of signature `function (value) {}` that validates the argument by returning a boolean. Also accepts a Joi schema. This key is required if `ref` is set to `true`.
- - `normalize`: A function of signature `function (value) {}` that normalizes the argument before passing it to `assert`.
- - `message`: A message to throw if `assert` is a function. This key is forbidden if `assert` is a schema.
- - `convert`: Whether this is a dual rule that converts the input value and validates it at the same time. Defaults to `false`.
- - `manifest`: Whether this rule should be outputted in the schema's description. Defaults to `true`.
- - `method`: The method that will be attached onto the schema instance. Useful when you need to set flags. If set to `undefined`, Joi will default to a function that when called will add the rule to the rules queue. If set to `false`, the no method will be added to the instance.
- - `multi`: Whether this rule can be invoked multiple times. Defaults to `false`.
- - `validate`: A function of signature `function (value, helpers, args, rule)` that validates the input value where:
- - `value`: The input value.
- - `helpers`: [Validation helpers](#validation-helpers)
- - `args`: Resolved and validated arguments mapped by their names.
- - `rule`: The rule definitions passed to `$_addRule` left untouched. Useful if you need access to the raw arguments before validation.
+ - `alias`: Aliases of the rule. Can be a string or an array of strings.
+ - `args`: An array of argument names or an object that define the parameters the rule will accept where:
+ - `name`: The argument name.
+ - `ref`: Whether this argument allows references. Joi will resolve them before passing to `validate`. Defaults to `false`.
+ - `assert`: A function of signature `function (value) {}` that validates the argument by returning a boolean. Also accepts a Joi schema. This key is required if `ref` is set to `true`.
+ - `normalize`: A function of signature `function (value) {}` that normalizes the argument before passing it to `assert`.
+ - `message`: A message to throw if `assert` is a function. This key is forbidden if `assert` is a schema.
+ - `convert`: Whether this is a dual rule that converts the input value and validates it at the same time. Defaults to `false`.
+ - `manifest`: Whether this rule should be outputted in the schema's description. Defaults to `true`.
+ - `method`: The method that will be attached onto the schema instance. Useful when you need to set flags. If set to `undefined`, Joi will default to a function that when called will add the rule to the rules queue. If set to `false`, the no method will be added to the instance.
+ - `multi`: Whether this rule can be invoked multiple times. Defaults to `false`.
+ - `validate`: A function of signature `function (value, helpers, args, rule)` that validates the input value where:
+ - `value`: The input value.
+ - `helpers`: [Validation helpers](#validation-helpers)
+ - `args`: Resolved and validated arguments mapped by their names.
+ - `rule`: The rule definitions passed to `$_addRule` left untouched. Useful if you need access to the raw arguments before validation.
- `overrides`: A hash of method names and their overridden implementation. To refer to the parent method, use [`$_parent()`](#\_parentmethod-args)
```js
const Joi = require('joi');
const custom = Joi.extend((joi) => {
- return {
- type: 'million',
- base: joi.number(),
- messages: {
- 'million.base': '{{#label}} must be at least a million',
- 'million.big': '{{#label}} must be at least five millions',
- 'million.round': '{{#label}} must be a round number',
- 'million.dividable': '{{#label}} must be dividable by {{#q}}',
- },
- coerce(value, helpers) {
- // Only called when prefs.convert is true
-
- if (helpers.schema.$_getRule('round')) {
- return { value: Math.round(value) };
- }
- },
- validate(value, helpers) {
- // Base validation regardless of the rules applied
-
- if (value < 1000000) {
- return { value, errors: helpers.error('million.base') };
- }
-
- // Check flags for global state
-
- if (helpers.schema.$_getFlag('big') && value < 5000000) {
- return { value, errors: helpers.error('million.big') };
- }
- },
- rules: {
- big: {
- alias: 'large',
- method() {
- return this.$_setFlag('big', true);
- },
- },
- round: {
- convert: true, // Dual rule: converts or validates
- method() {
- return this.$_addRule('round');
+ return {
+ type: 'million',
+ base: joi.number(),
+ messages: {
+ 'million.base': '{{#label}} must be at least a million',
+ 'million.big': '{{#label}} must be at least five millions',
+ 'million.round': '{{#label}} must be a round number',
+ 'million.dividable': '{{#label}} must be dividable by {{#q}}',
},
- validate(value, helpers, args, options) {
- // Only called when prefs.convert is false (due to rule convert option)
+ coerce(value, helpers) {
+ // Only called when prefs.convert is true
- if (value % 1 !== 0) {
- return helpers.error('million.round');
- }
- },
- },
- dividable: {
- multi: true, // Rule supports multiple invocations
- method(q) {
- return this.$_addRule({ name: 'dividable', args: { q } });
+ if (helpers.schema.$_getRule('round')) {
+ return { value: Math.round(value) };
+ }
},
- args: [
- {
- name: 'q',
- ref: true,
- assert: (value) => typeof value === 'number' && !isNaN(value),
- message: 'must be a number',
- },
- ],
- validate(value, helpers, args, options) {
- if (value % args.q === 0) {
- return value; // Value is valid
- }
+ validate(value, helpers) {
+ // Base validation regardless of the rules applied
- return helpers.error('million.dividable', { q: args.q });
- },
- },
- even: {
- method() {
- // Rule with only method used to alias another rule
+ if (value < 1000000) {
+ return { value, errors: helpers.error('million.base') };
+ }
- return this.dividable(2);
+ // Check flags for global state
+
+ if (helpers.schema.$_getFlag('big') && value < 5000000) {
+ return { value, errors: helpers.error('million.big') };
+ }
},
- },
- },
- };
+ rules: {
+ big: {
+ alias: 'large',
+ method() {
+ return this.$_setFlag('big', true);
+ },
+ },
+ round: {
+ convert: true, // Dual rule: converts or validates
+ method() {
+ return this.$_addRule('round');
+ },
+ validate(value, helpers, args, options) {
+ // Only called when prefs.convert is false (due to rule convert option)
+
+ if (value % 1 !== 0) {
+ return helpers.error('million.round');
+ }
+ },
+ },
+ dividable: {
+ multi: true, // Rule supports multiple invocations
+ method(q) {
+ return this.$_addRule({ name: 'dividable', args: { q } });
+ },
+ args: [
+ {
+ name: 'q',
+ ref: true,
+ assert: (value) =>
+ typeof value === 'number' && !isNaN(value),
+ message: 'must be a number',
+ },
+ ],
+ validate(value, helpers, args, options) {
+ if (value % args.q === 0) {
+ return value; // Value is valid
+ }
+
+ return helpers.error('million.dividable', { q: args.q });
+ },
+ },
+ even: {
+ method() {
+ // Rule with only method used to alias another rule
+
+ return this.dividable(2);
+ },
+ },
+ },
+ };
});
const schema = custom.object({
- a: custom.million().round().dividable(Joi.ref('b')),
- b: custom.number(),
- c: custom.million().even().dividable(7),
- d: custom.million().round().prefs({ convert: false }),
- e: custom.million().large(),
+ a: custom.million().round().dividable(Joi.ref('b')),
+ b: custom.number(),
+ c: custom.million().even().dividable(7),
+ d: custom.million().round().prefs({ convert: false }),
+ e: custom.million().large(),
});
```
@@ -3437,9 +3442,9 @@ const schema = custom.object({
- `schema`: The reference to the current schema. Useful if you need to use any of the [Advanced functions](#advanced-functions).
- `state`: The current validation state. See [Validation state](#validation-state).
- `error`: A function with signature `function (code, local, localState = currentState) {}` similar to [`$_createError()`](#\_createerrorcode-value-local-state-prefs-options) but with the current value, validation options, current state passed where:
- - `code`: The error code.
- - `local`: Local context used to interpolate the message.
- - `localState`: The localized state.
+ - `code`: The error code.
+ - `local`: Local context used to interpolate the message.
+ - `localState`: The localized state.
- `errorsArray`: A function that creates an array that can be recognised by Joi as a valid error array. **Note that using a native JS array can cause Joi to output incorrect results.**
- `warn`: TODO
- `message`: TODO
@@ -3480,10 +3485,10 @@ TODO
Adds a rule to the rules queue where:
- `options`: A rule name string or rule options where:
- - `name`: The name of the rule.
- - `args`: The arguments to be processed.
- - `method`: The name of another rule to reuse.
- You can also pass extra properties and they will be accessible within the `rule` argument of the `validate` method.
+ - `name`: The name of the rule.
+ - `args`: The arguments to be processed.
+ - `method`: The name of another rule to reuse.
+ You can also pass extra properties and they will be accessible within the `rule` argument of the `validate` method.
#### $\_compile(schema, options)
@@ -3550,7 +3555,7 @@ Sets a flag where:
- `name`: The flag name to set.
- `value`: The value to set the flag to.
- `options`: Optional options where:
- - `clone`: Whether to clone the schema. Defaults to `true`. Only set to `false` if the schema has already been cloned before.
+ - `clone`: Whether to clone the schema. Defaults to `true`. Only set to `false` if the schema has already been cloned before.
#### $\_validate(value, state, prefs)
@@ -3571,14 +3576,14 @@ Performs validation against the current schema without the extra overhead of mer
- `name` - `'ValidationError'`.
- `isJoi` - `true`.
- `details` - an array of errors :
- - `message` - string with a description of the error.
- - `path` - ordered array where each element is the accessor to the value where the error happened.
- - `type` - type of the error.
- - `context` - object providing context of the error containing:
- - `key` - key of the value that erred, equivalent to the last element of `details.path`.
- - `label` - label of the value that erred, or the `key` if any, or the default `messages.root`.
- - `value` - the value that failed validation.
- - other error specific properties as described for each error code.
+ - `message` - string with a description of the error.
+ - `path` - ordered array where each element is the accessor to the value where the error happened.
+ - `type` - type of the error.
+ - `context` - object providing context of the error containing:
+ - `key` - key of the value that erred, equivalent to the last element of `details.path`.
+ - `label` - label of the value that erred, or the `key` if any, or the default `messages.root`.
+ - `value` - the value that failed validation.
+ - other error specific properties as described for each error code.
- `annotate()` - function that returns a string with an annotated version of the object pointing at
the places where errors occurred. Takes an optional parameter that, if truthy, will strip the
colors out of the output.
@@ -3618,7 +3623,7 @@ Additional local context properties:
```ts
{
- types: Array; // The list of expected types
+ types: Array; // The list of expected types
}
```
@@ -3630,7 +3635,7 @@ Additional local context properties:
```ts
{
- error: Error; // The error thrown
+ error: Error; // The error thrown
}
```
@@ -3642,7 +3647,7 @@ Additional local context properties:
```ts
{
- error: Error; // Error generated during the default value function call
+ error: Error; // Error generated during the default value function call
}
```
@@ -3654,7 +3659,7 @@ Additional local context properties:
```ts
{
- error: Error; // Error generated during the failover value function call
+ error: Error; // Error generated during the failover value function call
}
```
@@ -3666,7 +3671,7 @@ Additional local context properties:
```ts
{
- invalids: Array; // Contains the list of the invalid values that should be rejected
+ invalids: Array; // Contains the list of the invalid values that should be rejected
}
```
@@ -3678,7 +3683,7 @@ Additional local context properties:
```ts
{
- valids: Array; // Contains the list of the valid values that were expected
+ valids: Array; // Contains the list of the valid values that were expected
}
```
@@ -3716,7 +3721,7 @@ Additional local context properties:
```ts
{
- pos: number; // Index where the value was found in the array
+ pos: number; // Index where the value was found in the array
}
```
@@ -3741,7 +3746,7 @@ Additional local context properties:
```ts
{
- knownMisses: Array; // Labels of all the missing values
+ knownMisses: Array; // Labels of all the missing values
}
```
@@ -3753,7 +3758,7 @@ Additional local context properties:
```ts
{
- unknownMisses: number; // Count of missing values that didn't have a label
+ unknownMisses: number; // Count of missing values that didn't have a label
}
```
@@ -3765,7 +3770,7 @@ Additional local context properties:
```ts
{
- pos: number; // Index where the value was found in the array
+ pos: number; // Index where the value was found in the array
}
```
@@ -3777,7 +3782,7 @@ Additional local context properties:
```ts
{
- limit: number; // Length that was expected for this array
+ limit: number; // Length that was expected for this array
}
```
@@ -3789,7 +3794,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum length that was expected for this array
+ limit: number; // Maximum length that was expected for this array
}
```
@@ -3801,7 +3806,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum length that was expected for this array
+ limit: number; // Minimum length that was expected for this array
}
```
@@ -3843,7 +3848,7 @@ Additional local context properties:
```ts
{
- type: string; // The unsupported array item type
+ type: string; // The unsupported array item type
}
```
@@ -3855,7 +3860,7 @@ Additional local context properties:
```ts
{
- pos: number; // Index where an undefined value was found in the array
+ pos: number; // Index where an undefined value was found in the array
}
```
@@ -3881,7 +3886,7 @@ Additional local context properties:
```ts
{
- patternLabel: string; // Label of assertion schema
+ patternLabel: string; // Label of assertion schema
}
```
@@ -3901,7 +3906,7 @@ Additional local context properties:
```ts
{
- limit: number; // Length that was expected for this buffer
+ limit: number; // Length that was expected for this buffer
}
```
@@ -3913,7 +3918,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum length that was expected for this buffer
+ limit: number; // Maximum length that was expected for this buffer
}
```
@@ -3925,7 +3930,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum length that was expected for this buffer
+ limit: number; // Minimum length that was expected for this buffer
}
```
@@ -3945,7 +3950,7 @@ Additional local context properties:
```ts
{
- format: string; // The required format
+ format: string; // The required format
}
```
@@ -3957,7 +3962,7 @@ Additional local context properties:
```ts
{
- limit: Date; // Maximum date
+ limit: Date; // Maximum date
}
```
@@ -3969,7 +3974,7 @@ Additional local context properties:
```ts
{
- limit: Date; // Minimum date
+ limit: Date; // Minimum date
}
```
@@ -3981,7 +3986,7 @@ Additional local context properties:
```ts
{
- limit: Date; // Maximum date
+ limit: Date; // Maximum date
}
```
@@ -3993,7 +3998,7 @@ Additional local context properties:
```ts
{
- limit: Date; // Minimum date
+ limit: Date; // Minimum date
}
```
@@ -4009,7 +4014,7 @@ Additional local context properties:
```ts
{
- n: number; // Expected arity
+ n: number; // Expected arity
}
```
@@ -4025,7 +4030,7 @@ Additional local context properties:
```ts
{
- n: number; // Maximum expected arity
+ n: number; // Maximum expected arity
}
```
@@ -4037,10 +4042,14 @@ Additional local context properties:
```ts
{
- n: number; // Minimum expected arity
+ n: number; // Minimum expected arity
}
```
+#### `link.depth`
+
+The validation chain exceeded the runtime call stack while resolving a recursive link. Returned instead of throwing a `RangeError`.
+
#### `number.base`
The value is not a number or could not be cast to a number.
@@ -4053,7 +4062,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum value that was expected for this number
+ limit: number; // Minimum value that was expected for this number
}
```
@@ -4073,7 +4082,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum value that was expected for this number
+ limit: number; // Maximum value that was expected for this number
}
```
@@ -4085,7 +4094,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum value that was expected for this number
+ limit: number; // Maximum value that was expected for this number
}
```
@@ -4097,7 +4106,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum value that was expected for this number
+ limit: number; // Minimum value that was expected for this number
}
```
@@ -4109,7 +4118,7 @@ Additional local context properties:
```ts
{
- multiple: number; // The number of which the input is supposed to be a multiple of
+ multiple: number; // The number of which the input is supposed to be a multiple of
}
```
@@ -4133,7 +4142,7 @@ Additional local context properties:
```ts
{
- limit: number; // The precision that it should have had
+ limit: number; // The precision that it should have had
}
```
@@ -4149,7 +4158,7 @@ Additional local context properties:
```ts
{
- child: string; // Property that is unexpected
+ child: string; // Property that is unexpected
}
```
@@ -4189,7 +4198,7 @@ Additional local context properties:
```ts
{
- type: string; // The expected type
+ type: string; // The expected type
}
```
@@ -4201,7 +4210,7 @@ Additional local context properties:
```ts
{
- limit: number; // Number of keys that was expected for this object
+ limit: number; // Number of keys that was expected for this object
}
```
@@ -4213,7 +4222,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum number of keys
+ limit: number; // Maximum number of keys
}
```
@@ -4225,7 +4234,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum number of keys
+ limit: number; // Minimum number of keys
}
```
@@ -4315,7 +4324,7 @@ Additional local context properties:
```ts
{
- type: string; // The required schema
+ type: string; // The required schema
}
```
@@ -4327,7 +4336,7 @@ Additional local context properties:
```ts
{
- type: string; // Type name the object should have been
+ type: string; // Type name the object should have been
}
```
@@ -4419,7 +4428,7 @@ Additional local context properties:
```ts
{
- invalids: [string]; // Array of invalid emails
+ invalids: [string]; // Array of invalid emails
}
```
@@ -4464,7 +4473,7 @@ Additional local context properties:
```ts
{
- cidr: string; // CIDR used for the validation
+ cidr: string; // CIDR used for the validation
}
```
@@ -4527,7 +4536,7 @@ Additional local context properties:
```ts
{
- form: string; // Normalization form that is expected
+ form: string; // Normalization form that is expected
}
```
@@ -4607,7 +4616,7 @@ Additional local context properties:
```ts
{
- scheme: string; // Scheme prefix that is expected in the URI
+ scheme: string; // Scheme prefix that is expected in the URI
}
```
diff --git a/generated/markdown/joi/18/api.md b/generated/markdown/joi/18/api.md
index 9d11488..21b8c90 100644
--- a/generated/markdown/joi/18/api.md
+++ b/generated/markdown/joi/18/api.md
@@ -8,24 +8,24 @@
const Joi = require('joi');
const schema = Joi.object({
- username: Joi.string().alphanum().min(3).max(30).required(),
+ username: Joi.string().alphanum().min(3).max(30).required(),
- password: Joi.string().pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')),
+ password: Joi.string().pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')),
- repeat_password: Joi.ref('password'),
+ repeat_password: Joi.ref('password'),
- access_token: [Joi.string(), Joi.number()],
+ access_token: [Joi.string(), Joi.number()],
- birth_year: Joi.number().integer().min(1900).max(2013),
+ birth_year: Joi.number().integer().min(1900).max(2013),
- email: Joi.string().email({
- minDomainSegments: 2,
- tlds: { allow: ['com', 'net'] },
- }),
+ email: Joi.string().email({
+ minDomainSegments: 2,
+ tlds: { allow: ['com', 'net'] },
+ }),
})
- .with('username', 'birth_year')
- .xor('password', 'access_token')
- .with('password', 'repeat_password');
+ .with('username', 'birth_year')
+ .xor('password', 'access_token')
+ .with('password', 'repeat_password');
schema.validate({ username: 'abc', birth_year: 1994 });
// -> { value: { username: 'abc', birth_year: 1994 } }
@@ -36,33 +36,33 @@ schema.validate({});
// Also -
try {
- const value = await schema.validateAsync({
- username: 'abc',
- birth_year: 1994,
- });
+ const value = await schema.validateAsync({
+ username: 'abc',
+ birth_year: 1994,
+ });
} catch (err) {}
```
The above schema defines the following constraints:
- `username`
- - a required string
- - must contain only alphanumeric characters
- - at least 3 characters long but no more than 30
- - must be accompanied by `birth_year`
+ - a required string
+ - must contain only alphanumeric characters
+ - at least 3 characters long but no more than 30
+ - must be accompanied by `birth_year`
- `password`
- - an optional string
- - must satisfy the custom regex pattern
- - cannot appear together with `access_token`
- - must be accompanied by `repeat_password` and equal to it
+ - an optional string
+ - must satisfy the custom regex pattern
+ - cannot appear together with `access_token`
+ - must be accompanied by `repeat_password` and equal to it
- `access_token`
- - an optional, unconstrained string or number
+ - an optional, unconstrained string or number
- `birth_year`
- - an integer between 1900 and 2013
+ - an integer between 1900 and 2013
- `email`
- - a valid email address string
- - must have two domain parts e.g. `example.com`
- - TLD must be `.com` or `.net`
+ - a valid email address string
+ - must have two domain parts e.g. `example.com`
+ - TLD must be `.com` or `.net`
### General Usage
@@ -72,7 +72,7 @@ First, a schema is constructed using the provided types and constraints:
```js
const schema = Joi.object({
- a: Joi.string(),
+ a: Joi.string(),
});
```
@@ -100,7 +100,7 @@ the module converts it internally to an object() type equivalent to:
```js
const schema = Joi.object().keys({
- a: Joi.string(),
+ a: Joi.string(),
});
```
@@ -108,17 +108,17 @@ When validating a schema:
- Values (or keys in case of objects) are optional by default.
- ```js
- Joi.string().validate(undefined); // validates fine
- ```
+ ```js
+ Joi.string().validate(undefined); // validates fine
+ ```
- To disallow this behavior, you can either set the schema as `required()`, or set `presence` to `"required"` when passing `options`:
+ To disallow this behavior, you can either set the schema as `required()`, or set `presence` to `"required"` when passing `options`:
- ```js
- Joi.string().required().validate(undefined);
- // or
- Joi.string().validate(undefined, /* options */ { presence: 'required' });
- ```
+ ```js
+ Joi.string().required().validate(undefined);
+ // or
+ Joi.string().validate(undefined, /* options */ { presence: 'required' });
+ ```
- Strings are utf-8 encoded by default.
- Rules are defined in an additive fashion and evaluated in order, first the inclusive rules, then the exclusive rules.
@@ -156,8 +156,8 @@ Provisions a simple LRU cache for caching simple inputs (`undefined`, `null`, st
booleans) where:
- `options` - optional settings:
- - `max` - number of items to store in the cache before the least used items are dropped.
- Defaults to `1000`.
+ - `max` - number of items to store in the cache before the least used items are dropped.
+ Defaults to `1000`.
### `checkPreferences(prefs)`
@@ -179,10 +179,10 @@ Converts literal schema definition to **joi** schema object (or returns the same
- `schema` - the schema definition to compile.
- `options` - optional settings:
- - `legacy` - if `true` and the provided schema is (or contains parts) using an older version of
- **joi**, will return a compiled schema that is compatible with the older version. If `false`,
- the schema is always compiled using the current version and if older schema components are
- found, an error is thrown.
+ - `legacy` - if `true` and the provided schema is (or contains parts) using an older version of
+ **joi**, will return a compiled schema that is compatible with the older version. If `false`,
+ the schema is always compiled using the current version and if older schema components are
+ found, an error is thrown.
```js
const definition = ['key', 5, { a: true, b: [/^a/, 'boom'] }];
@@ -191,15 +191,15 @@ const schema = Joi.compile(definition);
// Same as:
const schema = Joi.alternatives().try(
- Joi.string().valid('key'),
- Joi.number().valid(5),
- Joi.object({
- a: Joi.boolean().valid(true),
- b: Joi.alternatives().try(
- Joi.string().pattern(/^a/),
- Joi.string().valid('boom'),
- ),
- }),
+ Joi.string().valid('key'),
+ Joi.number().valid(5),
+ Joi.object({
+ a: Joi.boolean().valid(true),
+ b: Joi.alternatives().try(
+ Joi.string().pattern(/^a/),
+ Joi.string().valid('boom'),
+ ),
+ }),
);
```
@@ -212,14 +212,14 @@ where:
```js
const custom = Joi.defaults((schema) => {
- switch (schema.type) {
- case 'string':
- return schema.allow('');
- case 'object':
- return schema.min(1);
- default:
- return schema;
- }
+ switch (schema.type) {
+ case 'string':
+ return schema.allow('');
+ case 'object':
+ return schema.min(1);
+ default:
+ return schema;
+ }
});
const schema = custom.object(); // Returns Joi.object().min(1)
@@ -232,7 +232,7 @@ Generates a dynamic expression using a template string where:
- `template` - the template string using the [template syntax](#template-syntax).
- `options` - optional settings used when creating internal references. Supports the same options
as [`ref()`](#refkey-options), in addition to those options:
- - `functions` - an object with keys being function names and values being their implementation that will be executed when used in the expression. Using the same name as a built-in function will result in a local override. Note: carefully check your arguments depending on the situation where the expression is used.
+ - `functions` - an object with keys being function names and values being their implementation that will be executed when used in the expression. Using the same name as a built-in function will result in a local override. Note: carefully check your arguments depending on the situation where the expression is used.
#### Template syntax
@@ -282,8 +282,8 @@ Can only be used in rules that support in-references.
```js
const schema = Joi.object({
- a: Joi.array().items(Joi.number()),
- b: Joi.number().valid(Joi.in('a')),
+ a: Joi.array().items(Joi.number()),
+ b: Joi.number().valid(Joi.in('a')),
});
```
@@ -319,7 +319,7 @@ Checks whether or not the provided argument is a **joi** schema where:
- `schema` - the value being checked.
- `options` - optional settings:
- - `legacy` - if `true`, will identify schemas from older versions of joi, otherwise will throw an error. Defaults to `false`.
+ - `legacy` - if `true`, will identify schemas from older versions of joi, otherwise will throw an error. Defaults to `false`.
```js
const schema = Joi.any();
@@ -354,27 +354,27 @@ References support the following arguments:
- `key` - the reference target. References can point to sibling keys (`a.b`) or ancestor keys (`...a.b`) using the `.` separator. If a `key` starts with `$` is signifies a context reference which is looked up in the `context` option object. The `key` can start with one or more separator characters to indicate a [relative starting point](#Relative-references).
- `options` - optional settings:
- - `adjust` - a function with the signature `function(value)` where `value` is the resolved reference value and the return value is the adjusted value to use. For example `(value) => value + 5` will add 5 to the resolved value. Note that the `adjust` feature will not perform any type validation on the adjusted value and it must match the value expected by the rule it is used in. Cannot be used with `map`.
- - `map` - an array of array pairs using the format `[[key, value], [key, value]]` used to maps the resolved reference value to another value. If the resolved value is not in the map, it is returned as-is. Cannot be used with `adjust`.
- - `prefix` - overrides default prefix characters key string prefix. Can be set to `false` to disable all prefix parsing (treat keys as literal strings), or an object with specific overrides for:
- - `global` - references to the globally provided `context` preference. Defaults to `'$'`.
- - `local` - references to error-specific or rule specific context. Defaults to `'#'`.
- - `root` - references to the root value being validated. Defaults to `'/'`.
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `ancestor` - if set to a number, sets the reference [relative starting point](#Relative-references). Cannot be combined with separator prefix characters. Defaults to the reference key prefix (or `1` if none present).
- - `in` - creates an [in-reference](#inref-options).
- - `iterables` - when `true`, the reference resolves by reaching into maps and sets.
- - `render` - when `true`, the value of the reference is used instead of its name in error messages and template rendering. Defaults to `false`.
+ - `adjust` - a function with the signature `function(value)` where `value` is the resolved reference value and the return value is the adjusted value to use. For example `(value) => value + 5` will add 5 to the resolved value. Note that the `adjust` feature will not perform any type validation on the adjusted value and it must match the value expected by the rule it is used in. Cannot be used with `map`.
+ - `map` - an array of array pairs using the format `[[key, value], [key, value]]` used to maps the resolved reference value to another value. If the resolved value is not in the map, it is returned as-is. Cannot be used with `adjust`.
+ - `prefix` - overrides default prefix characters key string prefix. Can be set to `false` to disable all prefix parsing (treat keys as literal strings), or an object with specific overrides for:
+ - `global` - references to the globally provided `context` preference. Defaults to `'$'`.
+ - `local` - references to error-specific or rule specific context. Defaults to `'#'`.
+ - `root` - references to the root value being validated. Defaults to `'/'`.
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `ancestor` - if set to a number, sets the reference [relative starting point](#Relative-references). Cannot be combined with separator prefix characters. Defaults to the reference key prefix (or `1` if none present).
+ - `in` - creates an [in-reference](#inref-options).
+ - `iterables` - when `true`, the reference resolves by reaching into maps and sets.
+ - `render` - when `true`, the value of the reference is used instead of its name in error messages and template rendering. Defaults to `false`.
Note that references can only be used where explicitly supported such as in `valid()` or `invalid()` rules. If upwards (parents) references are needed, use [`object.assert()`](#objectassertref-schema-message).
```js
const schema = Joi.object({
- a: Joi.ref('b.c'),
- b: {
- c: Joi.any(),
- },
- c: Joi.ref('$x'),
+ a: Joi.ref('b.c'),
+ b: {
+ c: Joi.any(),
+ },
+ c: Joi.ref('$x'),
});
await schema.validateAsync({ a: 5, b: { c: 5 } }, { context: { x: 5 } });
@@ -481,7 +481,7 @@ const Joi = require('joi');
const { object, string } = Joi.types();
const schema = object.keys({
- property: string.min(4),
+ property: string.min(4),
});
```
@@ -515,8 +515,8 @@ To create an exclusive list of values, see [`any.valid(value)`](#anyvalidvalues-
```js
const schema = {
- a: Joi.any().allow('a'),
- b: Joi.any().allow('b', 'B'),
+ a: Joi.any().allow('a'),
+ b: Joi.any().allow('b', 'B'),
};
```
@@ -530,10 +530,10 @@ is called where:
```js
const schema = Joi.object({
- key: Joi.string().alter({
- get: (schema) => schema.required(),
- post: (schema) => schema.forbidden(),
- }),
+ key: Joi.string().alter({
+ get: (schema) => schema.required(),
+ post: (schema) => schema.forbidden(),
+ }),
});
const getSchema = schema.tailor('get');
@@ -548,10 +548,10 @@ Assigns the schema an artifact id which is included in the validation result if
```js
const schema = {
- a: [
- Joi.number().max(10).artifact('under'),
- Joi.number().min(11).artifact('over'),
- ],
+ a: [
+ Joi.number().max(10).artifact('under'),
+ Joi.number().min(11).artifact('over'),
+ ],
};
```
@@ -599,10 +599,10 @@ Note that `key` and `value` can be anything including objects, array, etc. It is
Casts the validated value to the specified type where:
- `to` - the value target type. Each **joi** schema type supports its own set of cast targets:
- - `'map'` - supported by the `Joi.object()` type, converts the result to a `Map` object containing the object key-value pairs.
- - `'number'` - supported by `Joi.boolean()` and `Joi.date()`, converts the result to a number. For dates, number of milliseconds since the epoch and for booleans, `0` for `false` and `1` for `true`.
- - `'set'` - supported by the `Joi.array()` type, converts the result to a `Set` object containing the array values.
- - `'string'` - supported by `Joi.binary()`, `Joi.boolean()`, `Joi.date()`, and `Joi.number()`, converts the result to a string.
+ - `'map'` - supported by the `Joi.object()` type, converts the result to a `Map` object containing the object key-value pairs.
+ - `'number'` - supported by `Joi.boolean()` and `Joi.date()`, converts the result to a number. For dates, number of milliseconds since the epoch and for booleans, `0` for `false` and `1` for `true`.
+ - `'set'` - supported by the `Joi.array()` type, converts the result to a `Set` object containing the array values.
+ - `'string'` - supported by `Joi.binary()`, `Joi.boolean()`, `Joi.date()`, and `Joi.number()`, converts the result to a string.
#### `any.concat(schema)`
@@ -621,42 +621,42 @@ const ab = a.concat(b);
Adds a custom validation function to execute arbitrary code where:
- `method` - the custom (synchronous only) validation function using signature `function(value, helpers)` where:
- - `value` - the value being validated.
- - `helpers` - an object with the following helpers:
- - `schema` - the current schema.
- - `state` - the current validation state.
- - `prefs` - the current preferences.
- - `original` - the original value passed into validation before any conversions.
- - `error(code, [local], [localState])` - a method to generate error codes using a message code, optional local context and optional validation local state.
- - `message(messages, [local])` - a method to generate an error with an internal `'custom'` error code and the provided messages object to use as override. Note that this is much slower than using the preferences `messages` option but is much simpler to write when performance is not important.
- - `warn(code, [local])` - a method to add a warning using a message code and optional local context.
+ - `value` - the value being validated.
+ - `helpers` - an object with the following helpers:
+ - `schema` - the current schema.
+ - `state` - the current validation state.
+ - `prefs` - the current preferences.
+ - `original` - the original value passed into validation before any conversions.
+ - `error(code, [local], [localState])` - a method to generate error codes using a message code, optional local context and optional validation local state.
+ - `message(messages, [local])` - a method to generate an error with an internal `'custom'` error code and the provided messages object to use as override. Note that this is much slower than using the preferences `messages` option but is much simpler to write when performance is not important.
+ - `warn(code, [local])` - a method to add a warning using a message code and optional local context.
Note: if the method fails to return a value, the value will be unset or returned as `undefined`.
```js
const method = (value, helpers) => {
- // Throw an error (will be replaced with 'any.custom' error)
- if (value === '1') {
- throw new Error('nope');
- }
-
- // Replace value with a new value
- if (value === '2') {
- return '3';
- }
-
- // Use error to return an existing error code
- if (value === '4') {
- return helpers.error('any.invalid');
- }
-
- // Override value with undefined to unset
- if (value === '5') {
- return undefined;
- }
-
- // Return the value unchanged
- return value;
+ // Throw an error (will be replaced with 'any.custom' error)
+ if (value === '1') {
+ throw new Error('nope');
+ }
+
+ // Replace value with a new value
+ if (value === '2') {
+ return '3';
+ }
+
+ // Use error to return an existing error code
+ if (value === '4') {
+ return helpers.error('any.invalid');
+ }
+
+ // Override value with undefined to unset
+ if (value === '5') {
+ return undefined;
+ }
+
+ // Return the value unchanged
+ return value;
};
const schema = Joi.string().custom(method, 'custom validation');
@@ -669,11 +669,11 @@ Possible validation errors: [`any.custom`](#anycustom)
Sets a default value if the original value is `undefined` where:
- `value` - the default value. One of:
- - a literal value (string, number, object, etc.).
- - a [references](#refkey-options).
- - a function which returns the default value using the signature `function(parent, helpers)` where:
- - `parent` - a clone of the object containing the value being validated. Note that since specifying a `parent` argument performs cloning, do not declare format arguments if you are not using them.
- - `helpers` - same as those described in [`any.custom()`](#anycustommethod_description).
+ - a literal value (string, number, object, etc.).
+ - a [references](#refkey-options).
+ - a function which returns the default value using the signature `function(parent, helpers)` where:
+ - `parent` - a clone of the object containing the value being validated. Note that since specifying a `parent` argument performs cloning, do not declare format arguments if you are not using them.
+ - `helpers` - same as those described in [`any.custom()`](#anycustommethod_description).
When called without any `value` on an object schema type, a default value will be automatically generated based on the default values of the object keys.
@@ -681,22 +681,22 @@ Note that if `value` is an object, any changes to the object after `default()` i
```js
const generateUsername = (parent, helpers) => {
- return parent.firstname.toLowerCase() + '-' + parent.lastname.toLowerCase();
+ return parent.firstname.toLowerCase() + '-' + parent.lastname.toLowerCase();
};
generateUsername.description = 'generated username';
const schema = Joi.object({
- username: Joi.string().default(generateUsername),
- firstname: Joi.string(),
- lastname: Joi.string(),
- created: Joi.date().default(Date.now),
- status: Joi.string().default('registered'),
+ username: Joi.string().default(generateUsername),
+ firstname: Joi.string(),
+ lastname: Joi.string(),
+ created: Joi.date().default(Date.now),
+ status: Joi.string().default('registered'),
});
const { value } = schema.validate({
- firstname: 'Jane',
- lastname: 'Doe',
+ firstname: 'Jane',
+ lastname: 'Doe',
});
// value.status === 'registered'
@@ -732,7 +732,7 @@ Annotates the key where:
```js
const schema = Joi.any().description(
- 'this key will match anything you give it',
+ 'this key will match anything you give it',
);
```
@@ -754,8 +754,8 @@ schema.validate(''); // returns { error: "value" is not allowed to be empty, val
Overrides the default **joi** error with a custom error if the rule fails where:
- `err` can be:
- - an instance of `Error` - the override error.
- - a function with the signature `function(errors)`, where `errors` is an array of validation reports and it returns either a single `Error` or an array of validation reports.
+ - an instance of `Error` - the override error.
+ - a function with the signature `function(errors)`, where `errors` is an array of validation reports and it returns either a single `Error` or an array of validation reports.
Do not use this method if you are simply trying to override the error message - use `any.message()` or `any.messages()` instead. This method is designed to override the **joi** validation error and return the exact override provided. It is useful when you want to return the result of validation directly (e.g. when using with a **hapi** server) and want to return a different HTTP error code than 400.
@@ -768,28 +768,28 @@ schema.validate(3); // returns Error('Was REALLY expecting a string')
```js
const schema = Joi.object({
- foo: Joi.number()
- .min(0)
- .error((errors) => new Error('"foo" requires a positive number')),
+ foo: Joi.number()
+ .min(0)
+ .error((errors) => new Error('"foo" requires a positive number')),
});
schema.validate({ foo: -2 }); // returns new Error('"foo" requires a positive number')
```
```js
const schema = Joi.object({
- foo: Joi.number()
- .min(0)
- .error((errors) => {
- return new Error(
- 'found errors with ' +
- errors
- .map(
- (err) =>
- `${err.local.key}(${err.local.limit}) with value ${err.local.value}`,
- )
- .join(' and '),
- );
- }),
+ foo: Joi.number()
+ .min(0)
+ .error((errors) => {
+ return new Error(
+ 'found errors with ' +
+ errors
+ .map(
+ (err) =>
+ `${err.local.key}(${err.local.limit}) with value ${err.local.value}`,
+ )
+ .join(' and '),
+ );
+ }),
});
schema.validate({ foo: -2 }); // returns new Error('found errors with foo(0) with value -2')
```
@@ -800,7 +800,7 @@ Adds examples to the schema where:
- `example` - adds an example. Note that no validation is performed on the value.
- `options` - optional settings:
- - `override` - if `true`, replaces any existing examples. Defaults to `false`.
+ - `override` - if `true`, replaces any existing examples. Defaults to `false`.
```js
const schema = Joi.string().min(4).example('abcd');
@@ -812,16 +812,16 @@ Adds an external validation rule where:
- `method` - an async or sync function with signature `function(value, helpers)` which can either
return a replacement value, `undefined` to indicate no change, or throw an error, where:
- - `value` - a clone of the object containing the value being validated.
- - `helpers` - an object with the following helpers:
- - `schema` - the current schema.
- - `linked` - if the schema is a link, the schema it links to.
- - `state` - the current validation state.
- - `prefs` - the current preferences.
- - `original` - the original value passed into validation before any conversions.
- - `error(code, [local])` - a method to generate error codes using a message code and optional local context.
- - `message(messages, [local])` - a method to generate an error with an internal `'external'` error code and the provided messages object to use as override. Note that this is much slower than using the preferences `messages` option but is much simpler to write when performance is not important.
- - `warn(code, [local])` - a method to add a warning using a message code and optional local context.
+ - `value` - a clone of the object containing the value being validated.
+ - `helpers` - an object with the following helpers:
+ - `schema` - the current schema.
+ - `linked` - if the schema is a link, the schema it links to.
+ - `state` - the current validation state.
+ - `prefs` - the current preferences.
+ - `original` - the original value passed into validation before any conversions.
+ - `error(code, [local])` - a method to generate error codes using a message code and optional local context.
+ - `message(messages, [local])` - a method to generate an error with an internal `'external'` error code and the provided messages object to use as override. Note that this is much slower than using the preferences `messages` option but is much simpler to write when performance is not important.
+ - `warn(code, [local])` - a method to add a warning using a message code and optional local context.
- `description` - optional string used to document the purpose of the method.
Note that external validation rules are only called after the all other validation rules for the
@@ -870,7 +870,7 @@ Marks a key as forbidden which will not allow any value except `undefined`. Used
```js
const schema = {
- a: Joi.any().forbidden(),
+ a: Joi.any().forbidden(),
};
```
@@ -904,8 +904,8 @@ Disallows values where:
```js
const schema = {
- a: Joi.any().invalid('a'),
- b: Joi.any().invalid('b', 'B'),
+ a: Joi.any().invalid('a'),
+ b: Joi.any().invalid('b', 'B'),
};
```
@@ -930,7 +930,7 @@ Overrides the key name in error messages.
```js
const schema = {
- first_name: Joi.string().label('First Name'),
+ first_name: Joi.string().label('First Name'),
};
```
@@ -1039,9 +1039,9 @@ Set the result mode where:
Applies a set of rule options to the current ruleset or last rule added where:
- `options` - the rules to apply where:
- - `keep` - if `true`, the rules will not be replaced by the same unique rule later. For example, `Joi.number().min(1).rule({ keep: true }).min(2)` will keep both `min()` rules instead of the later rule overriding the first. Defaults to `false`.
- - `message` - a single message string or a messages object where each key is an error code and corresponding message string as value. The object is the same as the `messages` used as an option in [`any.validate()`](#anyvalidatevalue-options). The strings can be plain messages or a message template.
- - `warn` - if `true`, turns any error generated by the ruleset to warnings.
+ - `keep` - if `true`, the rules will not be replaced by the same unique rule later. For example, `Joi.number().min(1).rule({ keep: true }).min(2)` will keep both `min()` rules instead of the later rule overriding the first. Defaults to `false`.
+ - `message` - a single message string or a messages object where each key is an error code and corresponding message string as value. The object is the same as the `messages` used as an option in [`any.validate()`](#anyvalidatevalue-options). The strings can be plain messages or a message template.
+ - `warn` - if `true`, turns any error generated by the ruleset to warnings.
When applying rule options, the last rule (e.g. `min()`) is used unless there is an active ruleset defined (e.g. `$.min().max()`) in which case the options are applied to all the provided rules. Once `rule()` is called, the previous rules can no longer be modified and any active ruleset is terminated.
@@ -1054,16 +1054,16 @@ Starts a ruleset in order to apply multiple [rule options](#anyruleoptions). The
```js
const schema = Joi.number()
- .ruleset.min(1)
- .max(10)
- .rule({ message: 'Number must be between 1 and 10' });
+ .ruleset.min(1)
+ .max(10)
+ .rule({ message: 'Number must be between 1 and 10' });
```
```js
const schema = Joi.number()
- .$.min(1)
- .max(10)
- .rule({ message: 'Number must be between 1 and 10' });
+ .$.min(1)
+ .max(10)
+ .rule({ message: 'Number must be between 1 and 10' });
```
#### `any.shared(schema)`
@@ -1074,11 +1074,11 @@ Registers a schema to be used by descendants of the current schema in named link
```js
const schema = Joi.object({
- a: [Joi.string(), Joi.link('#x')],
- b: Joi.link('#type.a'),
+ a: [Joi.string(), Joi.link('#x')],
+ b: Joi.link('#type.a'),
})
- .shared(Joi.number().id('x'))
- .id('type');
+ .shared(Joi.number().id('x'))
+ .id('type');
```
#### `any.strict(isStrict)`
@@ -1101,8 +1101,8 @@ where:
```js
const schema = Joi.object({
- username: Joi.string(),
- password: Joi.string().strip(),
+ username: Joi.string(),
+ password: Joi.string().strip(),
});
schema.validate({ username: 'test', password: 'hunter2' }); // result.value = { username: 'test' }
@@ -1131,10 +1131,10 @@ Applies any assigned target alterations to a copy of the schema that were applie
```js
const schema = Joi.object({
- key: Joi.string().alter({
- get: (schema) => schema.required(),
- post: (schema) => schema.forbidden(),
- }),
+ key: Joi.string().alter({
+ get: (schema) => schema.required(),
+ post: (schema) => schema.forbidden(),
+ }),
});
const getSchema = schema.tailor('get');
@@ -1159,8 +1159,8 @@ Adds the provided values into the allowed values list and marks them as the only
```js
const schema = {
- a: Joi.any().valid('a'),
- b: Joi.any().valid('b', 'B'),
+ a: Joi.any().valid('a'),
+ b: Joi.any().valid('b', 'B'),
};
```
@@ -1172,43 +1172,43 @@ Validates a value using the current schema and options where:
- `value` - the value being validated.
- `options` - an optional object with the following optional keys:
- - `abortEarly` - when `true`, stops validation on the first error, otherwise returns all the errors found. Defaults to `true`.
- - `allowUnknown` - when `true`, allows object to contain unknown keys which are ignored. Defaults to `false`.
- - `cache` - when `true`, schema caching is enabled (for schemas with explicit caching rules). Default to `true`.
- - `context` - provides an external data set to be used in [references](#refkey-options). Can only be set as an external option to `validate()` and not using `any.prefs()`.
- - `convert` - when `true`, attempts to cast values to the required types (e.g. a string to a number). Defaults to `true`.
- - `dateFormat` - sets the string format used when converting dates to strings in error messages and casting. Options are:
- - `'date'` - date string.
- - `'iso'` - date time ISO string. This is the default.
- - `'string'` - JS default date time string.
- - `'time'` - time string.
- - `'utc'` - UTC date time string.
- - `debug` - when `true`, valid results and throw errors are decorated with a `debug` property which includes an array of the validation steps used to generate the returned result. Defaults to `false`.
- - `errors` - error formatting settings:
- - `escapeHtml` - when `true`, error message templates will escape special characters to HTML entities, for security purposes. Defaults to `false`.
- - `label` - defines the value used to set the `label` context variable:
- - `'path'` - the full path to the value being validated. This is the default value.
- - `'key'` - the key of the value being validated.
- - `false` - remove any label prefix from error message, including the `""`.
- - `language` - the preferred language code for error messages. The value is matched against keys at the root of the `messages` object, and then the error code as a child key of that. Can be a reference to the value, global context, or local context which is the root value passed to the validation function. Note that references to the value are usually not what you want as they move around the value structure relative to where the error happens. Instead, either use the global context, or the absolute value (e.g. `Joi.ref('/variable')`);
- - `render` - when `false`, skips rendering error templates. Useful when error messages are generated elsewhere to save processing time. Defaults to `true`.
- - `stack` - when `true`, the main error will possess a stack trace, otherwise it will be disabled. Defaults to `false` for performance reasons. Has no effect on platforms other than V8/node.js as it uses the [Stack trace API](https://v8.dev/docs/stack-trace-api).
- - `wrap` - overrides the way values are wrapped (e.g. `[]` around arrays, `""` around labels and variables prefixed with `:`). Each key can be set to a string with one (same character before and after the value) or two characters (first character before and second character after), or `false` to disable wrapping:
- - `label` - the characters used around `{#label}` references. Defaults to `'"'`.
- - `array` - the characters used around array values. Defaults to `'[]'`.
- - `string` - the characters used around each array string values. Defaults to `false`.
- - `wrapArrays` - if `true`, array values in error messages are wrapped in `[]`. Defaults to `true`.
- - `externals` - if `false`, the external rules set with [`any.external()`](#anyexternalmethod-description) are ignored, which is required to ignore any external validations in synchronous mode (or an exception is thrown). Defaults to `true`.
- - `messages` - overrides individual error messages. Defaults to no override (`{}`). Use the `'*'` error code as a catch-all for all error codes that do not have a message provided in the override. Messages use the same rules as [templates](#template-syntax). Variables in double braces `{{var}}` are HTML escaped if the option `errors.escapeHtml` is set to `true`.
- - `noDefaults` - when `true`, do not apply default values. Defaults to `false`.
- - `nonEnumerables` - when `true`, inputs are shallow cloned to include non-enumerable properties. Defaults to `false`.
- - `presence` - sets the default presence requirements. Supported modes: `'optional'`, `'required'`, and `'forbidden'`. Defaults to `'optional'`.
- - `skipFunctions` - when `true`, ignores unknown keys with a function value. Defaults to `false`.
- - `stripUnknown` - remove unknown elements from objects and arrays. Defaults to `false`.
- - when an `object` :
- - `arrays` - set to `true` to remove unknown items from arrays.
- - `objects` - set to `true` to remove unknown keys from objects.
- - when `true`, it is equivalent to having `{ arrays: false, objects: true }`.
+ - `abortEarly` - when `true`, stops validation on the first error, otherwise returns all the errors found. Defaults to `true`.
+ - `allowUnknown` - when `true`, allows object to contain unknown keys which are ignored. Defaults to `false`.
+ - `cache` - when `true`, schema caching is enabled (for schemas with explicit caching rules). Default to `true`.
+ - `context` - provides an external data set to be used in [references](#refkey-options). Can only be set as an external option to `validate()` and not using `any.prefs()`.
+ - `convert` - when `true`, attempts to cast values to the required types (e.g. a string to a number). Defaults to `true`.
+ - `dateFormat` - sets the string format used when converting dates to strings in error messages and casting. Options are:
+ - `'date'` - date string.
+ - `'iso'` - date time ISO string. This is the default.
+ - `'string'` - JS default date time string.
+ - `'time'` - time string.
+ - `'utc'` - UTC date time string.
+ - `debug` - when `true`, valid results and throw errors are decorated with a `debug` property which includes an array of the validation steps used to generate the returned result. Defaults to `false`.
+ - `errors` - error formatting settings:
+ - `escapeHtml` - when `true`, error message templates will escape special characters to HTML entities, for security purposes. Defaults to `false`.
+ - `label` - defines the value used to set the `label` context variable:
+ - `'path'` - the full path to the value being validated. This is the default value.
+ - `'key'` - the key of the value being validated.
+ - `false` - remove any label prefix from error message, including the `""`.
+ - `language` - the preferred language code for error messages. The value is matched against keys at the root of the `messages` object, and then the error code as a child key of that. Can be a reference to the value, global context, or local context which is the root value passed to the validation function. Note that references to the value are usually not what you want as they move around the value structure relative to where the error happens. Instead, either use the global context, or the absolute value (e.g. `Joi.ref('/variable')`);
+ - `render` - when `false`, skips rendering error templates. Useful when error messages are generated elsewhere to save processing time. Defaults to `true`.
+ - `stack` - when `true`, the main error will possess a stack trace, otherwise it will be disabled. Defaults to `false` for performance reasons. Has no effect on platforms other than V8/node.js as it uses the [Stack trace API](https://v8.dev/docs/stack-trace-api).
+ - `wrap` - overrides the way values are wrapped (e.g. `[]` around arrays, `""` around labels and variables prefixed with `:`). Each key can be set to a string with one (same character before and after the value) or two characters (first character before and second character after), or `false` to disable wrapping:
+ - `label` - the characters used around `{#label}` references. Defaults to `'"'`.
+ - `array` - the characters used around array values. Defaults to `'[]'`.
+ - `string` - the characters used around each array string values. Defaults to `false`.
+ - `wrapArrays` - if `true`, array values in error messages are wrapped in `[]`. Defaults to `true`.
+ - `externals` - if `false`, the external rules set with [`any.external()`](#anyexternalmethod-description) are ignored, which is required to ignore any external validations in synchronous mode (or an exception is thrown). Defaults to `true`.
+ - `messages` - overrides individual error messages. Defaults to no override (`{}`). Use the `'*'` error code as a catch-all for all error codes that do not have a message provided in the override. Messages use the same rules as [templates](#template-syntax). Variables in double braces `{{var}}` are HTML escaped if the option `errors.escapeHtml` is set to `true`.
+ - `noDefaults` - when `true`, do not apply default values. Defaults to `false`.
+ - `nonEnumerables` - when `true`, inputs are shallow cloned to include non-enumerable properties. Defaults to `false`.
+ - `presence` - sets the default presence requirements. Supported modes: `'optional'`, `'required'`, and `'forbidden'`. Defaults to `'optional'`.
+ - `skipFunctions` - when `true`, ignores unknown keys with a function value. Defaults to `false`.
+ - `stripUnknown` - remove unknown elements from objects and arrays. Defaults to `false`.
+ - when an `object` :
+ - `arrays` - set to `true` to remove unknown items from arrays.
+ - `objects` - set to `true` to remove unknown keys from objects.
+ - when `true`, it is equivalent to having `{ arrays: false, objects: true }`.
Returns an object with the following keys:
@@ -1219,11 +1219,11 @@ Returns an object with the following keys:
```js
const schema = Joi.object({
- a: Joi.number(),
+ a: Joi.number(),
});
const value = {
- a: '123',
+ a: '123',
};
const result = schema.validate(value);
@@ -1236,23 +1236,23 @@ Validates a value asynchronously using the current schema and options where:
- `value` - the value being validated.
- `options` - an optional object as described in [`any.validate()`](#anyvalidatevalue-options), with the following additional settings:
- - `artifacts` - when `true`, artifacts are returned alongside the value (i.e. `{ value, artifacts }`). Defaults to `false`.
- - `warnings` - when `true`, warnings are returned alongside the value (i.e. `{ value, warning }`). Defaults to `false`.
+ - `artifacts` - when `true`, artifacts are returned alongside the value (i.e. `{ value, artifacts }`). Defaults to `false`.
+ - `warnings` - when `true`, warnings are returned alongside the value (i.e. `{ value, warning }`). Defaults to `false`.
Returns a Promise that resolves into the validated value when the value is valid. If the value is valid and the `warnings` or `debug` options are set to `true`, returns an object `{ value, warning, debug }`. If validation fails, the promise rejects with the validation error.
```js
const schema = Joi.object({
- a: Joi.number(),
+ a: Joi.number(),
});
const value = {
- a: '123',
+ a: '123',
};
try {
- const value = await schema.validateAsync(value);
- // value -> { "a" : 123 }
+ const value = await schema.validateAsync(value);
+ // value -> { "a" : 123 }
} catch (err) {}
```
@@ -1273,8 +1273,8 @@ When calling [`any.validateAsync()`](#anyvalidateasyncvalue-options), set the `w
```js
const schema = Joi.any()
- .warning('custom.x', { w: 'world' })
- .message({ 'custom.x': 'hello {#w}!' });
+ .warning('custom.x', { w: 'world' })
+ .message({ 'custom.x': 'hello {#w}!' });
const { value, error, warning } = schema.validate('anything');
@@ -1285,11 +1285,11 @@ const { value, error, warning } = schema.validate('anything');
// or
try {
- const { value, warning } = await schema.validateAsync('anything', {
- warnings: true,
- });
- // value -> 'anything';
- // warning -> { message: 'hello world!', details: [...] }
+ const { value, warning } = await schema.validateAsync('anything', {
+ warnings: true,
+ });
+ // value -> 'anything';
+ // warning -> { message: 'hello world!', details: [...] }
} catch (err) {}
```
@@ -1316,12 +1316,12 @@ Adds conditions that are evaluated during validation and modify the schema befor
- `condition` - a key name, [reference](#refkey-options), or a schema. If omitted, defaults to `Joi.ref('.')`.
- `options` - an object with:
- - `is` - the condition expressed as a **joi** schema. Anything that is not a **joi** schema will be converted using [Joi.compile](#compileschema-options). By default, the `is` condition schema allows for `undefined` values. Use `.required()` to override. For example, use `is: Joi.number().required()` to guarantee that a **joi** reference exists and is a number.
- - `not` - the negative version of `is` (`then` and `otherwise` have reverse roles).
- - `then` - if the condition is true, the **joi** schema to use.
- - `otherwise` - if the condition is false, the **joi** schema to use.
- - `switch` - an array of `{ is, then }` conditions that are evaluated against the `condition`. The last item in the array may also contain `otherwise`.
- - `break` - stops processing all other conditions if the rule results in a `then`, `otherwise`, of `switch` match.
+ - `is` - the condition expressed as a **joi** schema. Anything that is not a **joi** schema will be converted using [Joi.compile](#compileschema-options). By default, the `is` condition schema allows for `undefined` values. Use `.required()` to override. For example, use `is: Joi.number().required()` to guarantee that a **joi** reference exists and is a number.
+ - `not` - the negative version of `is` (`then` and `otherwise` have reverse roles).
+ - `then` - if the condition is true, the **joi** schema to use.
+ - `otherwise` - if the condition is false, the **joi** schema to use.
+ - `switch` - an array of `{ is, then }` conditions that are evaluated against the `condition`. The last item in the array may also contain `otherwise`.
+ - `break` - stops processing all other conditions if the rule results in a `then`, `otherwise`, of `switch` match.
If `condition` is a reference:
@@ -1345,16 +1345,16 @@ Notes:
```js
const schema = {
- a: Joi.any()
- .valid('x')
- .when('b', {
- is: Joi.exist(),
- then: Joi.valid('y'),
- otherwise: Joi.valid('z'),
- })
- .when('c', { is: Joi.number().min(10), then: Joi.forbidden() }),
- b: Joi.any(),
- c: Joi.number(),
+ a: Joi.any()
+ .valid('x')
+ .when('b', {
+ is: Joi.exist(),
+ then: Joi.valid('y'),
+ otherwise: Joi.valid('z'),
+ })
+ .when('c', { is: Joi.number().min(10), then: Joi.forbidden() }),
+ b: Joi.any(),
+ c: Joi.number(),
};
```
@@ -1362,15 +1362,15 @@ Or with a schema:
```js
const schema = Joi.object({
- a: Joi.any().valid('x'),
- b: Joi.any(),
+ a: Joi.any().valid('x'),
+ b: Joi.any(),
}).when(Joi.object({ b: Joi.exist() }).unknown(), {
- then: Joi.object({
- a: Joi.valid('y'),
- }),
- otherwise: Joi.object({
- a: Joi.valid('z'),
- }),
+ then: Joi.object({
+ a: Joi.valid('y'),
+ }),
+ otherwise: Joi.object({
+ a: Joi.valid('z'),
+ }),
});
```
@@ -1380,16 +1380,16 @@ validate this logic:
```js
const schema = Joi.object({
- type: Joi.string().valid('A', 'B', 'C').required(), // required if type == 'A'
+ type: Joi.string().valid('A', 'B', 'C').required(), // required if type == 'A'
- foo: Joi.when('type', {
- is: 'A',
- then: Joi.string().valid('X', 'Y', 'Z').required(),
- }), // required if type === 'A' and foo !== 'Z'
+ foo: Joi.when('type', {
+ is: 'A',
+ then: Joi.string().valid('X', 'Y', 'Z').required(),
+ }), // required if type === 'A' and foo !== 'Z'
- bar: Joi.string(),
+ bar: Joi.string(),
}).when(Joi.object({ type: Joi.valid('A'), foo: Joi.not('Z') }).unknown(), {
- then: Joi.object({ bar: Joi.required() }),
+ then: Joi.object({ bar: Joi.required() }),
});
```
@@ -1398,8 +1398,8 @@ like this:
```js
const schema = {
- a: Joi.valid('a', 'b', 'other'),
- other: Joi.string().when('a', { is: 'other', then: Joi.required() }),
+ a: Joi.valid('a', 'b', 'other'),
+ other: Joi.string().when('a', { is: 'other', then: Joi.required() }),
};
```
@@ -1408,17 +1408,17 @@ so like this:
```js
const schema = Joi.object({
- a: Joi.boolean().required(),
- b: Joi.object()
- .keys({
- c: Joi.string(),
- d: Joi.number().required(),
- })
- .required()
- .when('a', {
- is: true,
- then: Joi.object({ c: Joi.required() }), // b.c is required only when a is true
- }),
+ a: Joi.boolean().required(),
+ b: Joi.object()
+ .keys({
+ c: Joi.string(),
+ d: Joi.number().required(),
+ })
+ .required()
+ .when('a', {
+ is: true,
+ then: Joi.object({ c: Joi.required() }), // b.c is required only when a is true
+ }),
});
```
@@ -1427,11 +1427,11 @@ following (notice the use of `required()`):
```js
const schema = Joi.object({
- min: Joi.number(),
- max: Joi.number().when('min', {
- is: Joi.number().required(),
- then: Joi.number().greater(Joi.ref('min')),
- }),
+ min: Joi.number(),
+ max: Joi.number().when('min', {
+ is: Joi.number().required(),
+ then: Joi.number().greater(Joi.ref('min')),
+ }),
});
```
@@ -1439,15 +1439,15 @@ To evaluate multiple values on a single reference:
```js
const schema = Joi.object({
- a: Joi.number().required(),
- b: Joi.number().when('a', {
- switch: [
- { is: 0, then: Joi.valid(1) },
- { is: 1, then: Joi.valid(2) },
- { is: 2, then: Joi.valid(3) },
- ],
- otherwise: Joi.valid(4),
- }),
+ a: Joi.number().required(),
+ b: Joi.number().when('a', {
+ switch: [
+ { is: 0, then: Joi.valid(1) },
+ { is: 1, then: Joi.valid(2) },
+ { is: 2, then: Joi.valid(3) },
+ ],
+ otherwise: Joi.valid(4),
+ }),
});
```
@@ -1455,12 +1455,12 @@ Or shorter:
```js
const schema = Joi.object({
- a: Joi.number().required(),
- b: Joi.number().when('a', [
- { is: 0, then: 1 },
- { is: 1, then: 2 },
- { is: 2, then: 3, otherwise: 4 },
- ]),
+ a: Joi.number().required(),
+ b: Joi.number().when('a', [
+ { is: 0, then: 1 },
+ { is: 1, then: 2 },
+ { is: 2, then: 3, otherwise: 4 },
+ ]),
});
```
@@ -1488,11 +1488,11 @@ Adds a conditional alternative schema type, either based on another key value, o
- `condition` - the key name or [reference](#refkey-options), or a schema.
- `options` - an object with:
- - `is` - the condition expressed as a **joi** schema. Anything that is not a **joi** schema will be converted using [Joi.compile](#compileschema-options).
- - `not` - the negative version of `is` (`then` and `otherwise` have reverse roles).
- - `then` - if the condition is true, the **joi** schema to use.
- - `otherwise` - if the condition is false, the **joi** schema to use.
- - `switch` - an array of `{ is, then }` conditions that are evaluated against the `condition`. The last item in the array may also contain `otherwise`.
+ - `is` - the condition expressed as a **joi** schema. Anything that is not a **joi** schema will be converted using [Joi.compile](#compileschema-options).
+ - `not` - the negative version of `is` (`then` and `otherwise` have reverse roles).
+ - `then` - if the condition is true, the **joi** schema to use.
+ - `otherwise` - if the condition is false, the **joi** schema to use.
+ - `switch` - an array of `{ is, then }` conditions that are evaluated against the `condition`. The last item in the array may also contain `otherwise`.
If `condition` is a reference:
@@ -1513,25 +1513,25 @@ Note that `alternatives.conditional()` is different than `any.when()`. When you
```js
const schema = {
- a: Joi.alternatives().conditional('b', {
- is: 5,
- then: Joi.string(),
- otherwise: Joi.number(),
- }),
- b: Joi.any(),
+ a: Joi.alternatives().conditional('b', {
+ is: 5,
+ then: Joi.string(),
+ otherwise: Joi.number(),
+ }),
+ b: Joi.any(),
};
```
```js
const schema = Joi.alternatives().conditional(Joi.object({ b: 5 }).unknown(), {
- then: Joi.object({
- a: Joi.string(),
- b: Joi.any(),
- }),
- otherwise: Joi.object({
- a: Joi.number(),
- b: Joi.any(),
- }),
+ then: Joi.object({
+ a: Joi.string(),
+ b: Joi.any(),
+ }),
+ otherwise: Joi.object({
+ a: Joi.number(),
+ b: Joi.any(),
+ }),
});
```
@@ -1541,8 +1541,8 @@ this definition of `a`:
```js
const schema = {
- a: Joi.alternatives().conditional('b', { is: true, then: Joi.required() }),
- b: Joi.boolean(),
+ a: Joi.alternatives().conditional('b', { is: true, then: Joi.required() }),
+ b: Joi.boolean(),
};
```
@@ -1555,8 +1555,8 @@ To accomplish the desired result above use:
```js
const schema = {
- a: Joi.when('b', { is: true, then: Joi.required() }),
- b: Joi.boolean(),
+ a: Joi.when('b', { is: true, then: Joi.required() }),
+ b: Joi.boolean(),
};
```
@@ -1565,9 +1565,9 @@ const schema = {
Requires the validated value to match a specific set of the provided `alternative.try()` schemas where:
- `mode` - the match mode which can be one of:
- - `'any'` - match any provided schema. This is the default value.
- - `'all'` - match all of the provided schemas. Note that this will ignore any conversions performed by the matchin schemas and return the raw value provided regardless of the `convert` preference set.
- - `'one'` - match one and only one of the provided schemas.
+ - `'any'` - match any provided schema. This is the default value.
+ - `'all'` - match all of the provided schemas. Note that this will ignore any conversions performed by the matchin schemas and return the raw value provided regardless of the `convert` preference set.
+ - `'one'` - match one and only one of the provided schemas.
Note: Cannot be combined with `alternatives.conditional()`.
@@ -1607,13 +1607,13 @@ Verifies that a schema validates at least one of the values in the array, where:
```js
const schema = Joi.array()
- .items(
- Joi.object({
- a: Joi.string(),
- b: Joi.number(),
- }),
- )
- .has(Joi.object({ a: Joi.string().valid('a'), b: Joi.number() }));
+ .items(
+ Joi.object({
+ a: Joi.string(),
+ b: Joi.number(),
+ }),
+ )
+ .has(Joi.object({ a: Joi.string().valid('a'), b: Joi.number() }));
```
Possible validation errors: [`array.hasKnown`](#arrayhasknown), [`array.hasUnknown`](#arrayhasunknown)
@@ -1632,16 +1632,16 @@ Errors will contain the number of items that didn't match. Any unmatched item ha
```js
const schema = Joi.array().items(Joi.string(), Joi.number()); // array may contain strings and numbers
const schema = Joi.array().items(
- Joi.string().required(),
- Joi.string().required(),
+ Joi.string().required(),
+ Joi.string().required(),
); // array must contain at least two strings
const schema = Joi.array().items(
- Joi.string().valid('not allowed').forbidden(),
- Joi.string(),
+ Joi.string().valid('not allowed').forbidden(),
+ Joi.string(),
); // array may contain strings, but none of those strings can match 'not allowed'
const schema = Joi.array().items(
- Joi.string().label('My string').required(),
- Joi.number().required(),
+ Joi.string().label('My string').required(),
+ Joi.number().required(),
); // If this fails it can result in `[ValidationError: "value" does not contain [My string] and 1 other required value(s)]`
```
@@ -1659,8 +1659,8 @@ const schema = Joi.array().length(5);
```js
const schema = Joi.object({
- limit: Joi.number().integer().required(),
- numbers: Joi.array().length(Joi.ref('limit')).required(),
+ limit: Joi.number().integer().required(),
+ numbers: Joi.array().length(Joi.ref('limit')).required(),
});
```
@@ -1678,8 +1678,8 @@ const schema = Joi.array().max(10);
```js
const schema = Joi.object({
- limit: Joi.number().integer().required(),
- numbers: Joi.array().max(Joi.ref('limit')).required(),
+ limit: Joi.number().integer().required(),
+ numbers: Joi.array().max(Joi.ref('limit')).required(),
});
```
@@ -1697,8 +1697,8 @@ const schema = Joi.array().min(2);
```js
const schema = Joi.object({
- limit: Joi.number().integer().required(),
- numbers: Joi.array().min(Joi.ref('limit')).required(),
+ limit: Joi.number().integer().required(),
+ numbers: Joi.array().min(Joi.ref('limit')).required(),
});
```
@@ -1715,12 +1715,12 @@ Errors will contain the number of items that didn't match. Any unmatched item ha
```js
const schema = Joi.array().ordered(
- Joi.string().required(),
- Joi.number().required(),
+ Joi.string().required(),
+ Joi.number().required(),
); // array must have first item as string and second item as number
const schema = Joi.array()
- .ordered(Joi.string().required())
- .items(Joi.number().required()); // array must have first item as string and 1 or more subsequent items as number
+ .ordered(Joi.string().required())
+ .items(Joi.number().required()); // array must have first item as string and 1 or more subsequent items as number
const schema = Joi.array().ordered(Joi.string().required(), Joi.number()); // array must have first item as string and optionally second item as number
```
@@ -1745,10 +1745,10 @@ Possible validation errors: [`array.excludes`](#arrayexcludes), [`array.includes
Requires the array to comply with the specified sort order where:
- `options` - optional settings:
- - `order` - the sort order. Allowed values:
- - `'ascending'` - sort the array in ascending order. This is the default.
- - `'descending'` - sort the array in descending order.
- - `by` - a key name or reference to sort array objects by. Defaults to the entire value.
+ - `order` - the sort order. Allowed values:
+ - `'ascending'` - sort the array in ascending order. This is the default.
+ - `'descending'` - sort the array in descending order.
+ - `by` - a key name or reference to sort array objects by. Defaults to the entire value.
Notes:
@@ -1774,16 +1774,16 @@ Possible validation errors: [`array.sparse`](#arraysparse)
Requires the array values to be unique where:
- `comparator` - an optional custom `comparator` that is either:
- - a function that takes 2 parameters to compare. This function should return whether the 2
- parameters are equal or not, you are also **responsible** for this function not to fail, any
- `Error` would bubble out of Joi.
- - a string in dot notation representing the path of the element to do uniqueness check on. Any
- missing path will be considered undefined, and can as well only exist once.
+ - a function that takes 2 parameters to compare. This function should return whether the 2
+ parameters are equal or not, you are also **responsible** for this function not to fail, any
+ `Error` would bubble out of Joi.
+ - a string in dot notation representing the path of the element to do uniqueness check on. Any
+ missing path will be considered undefined, and can as well only exist once.
- `options` - optional settings:
- - `ignoreUndefined` - if `true`, undefined values for the dot notation string comparator will
- not cause the array to fail on uniqueness. Defaults to `false`.
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the
- `key` as a literal value.
+ - `ignoreUndefined` - if `true`, undefined values for the dot notation string comparator will
+ not cause the array to fail on uniqueness. Defaults to `false`.
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the
+ `key` as a literal value.
Note: remember that if you provide a custom comparator function, different types can be passed as parameter depending on the rules you set on items.
@@ -1957,8 +1957,8 @@ const schema = Joi.date().greater('now');
```js
const schema = Joi.object({
- from: Joi.date().required(),
- to: Joi.date().greater(Joi.ref('from')).required(),
+ from: Joi.date().required(),
+ to: Joi.date().greater(Joi.ref('from')).required(),
});
```
@@ -1990,8 +1990,8 @@ const schema = Joi.date().less('now');
```js
const schema = Joi.object({
- from: Joi.date().less(Joi.ref('to')).required(),
- to: Joi.date().required(),
+ from: Joi.date().less(Joi.ref('to')).required(),
+ to: Joi.date().required(),
});
```
@@ -2015,8 +2015,8 @@ const schema = Joi.date().max('now');
```js
const schema = Joi.object({
- from: Joi.date().max(Joi.ref('to')).required(),
- to: Joi.date().required(),
+ from: Joi.date().max(Joi.ref('to')).required(),
+ to: Joi.date().required(),
});
```
@@ -2040,8 +2040,8 @@ const schema = Joi.date().min('now');
```js
const schema = Joi.object({
- from: Joi.date().required(),
- to: Joi.date().min(Joi.ref('from')).required(),
+ from: Joi.date().required(),
+ to: Joi.date().min(Joi.ref('from')).required(),
});
```
@@ -2148,9 +2148,9 @@ Named links:
```js
const person = Joi.object({
- firstName: Joi.string().required(),
- lastName: Joi.string().required(),
- children: Joi.array().items(Joi.link('#person')),
+ firstName: Joi.string().required(),
+ lastName: Joi.string().required(),
+ children: Joi.array().items(Joi.link('#person')),
}).id('person');
```
@@ -2158,12 +2158,12 @@ Relative links:
```js
const person = Joi.object({
- firstName: Joi.string().required(),
- lastName: Joi.string().required(),
- children: Joi.array().items(Joi.link('...')),
- // . - the link
- // .. - the children array
- // ... - the person object
+ firstName: Joi.string().required(),
+ lastName: Joi.string().required(),
+ children: Joi.array().items(Joi.link('...')),
+ // . - the link
+ // .. - the children array
+ // ... - the person object
});
```
@@ -2171,9 +2171,9 @@ Absolute links:
```js
const person = Joi.object({
- firstName: Joi.string().required(),
- lastName: Joi.string().required(),
- children: Joi.array().items(Joi.link('/')),
+ firstName: Joi.string().required(),
+ lastName: Joi.string().required(),
+ children: Joi.array().items(Joi.link('/')),
});
```
@@ -2186,8 +2186,8 @@ Will throw an error during validation if left uninitialized (e.g. `Joi.link()` c
```js
const schema = Joi.object({
- a: [Joi.string(), Joi.number()],
- b: Joi.link().ref('#type.a'),
+ a: [Joi.string(), Joi.number()],
+ b: Joi.link().ref('#type.a'),
}).id('type');
```
@@ -2205,8 +2205,8 @@ Validation fails with the `link.maxRecursion` error code when the limit is excee
```js
const schema = Joi.object({
- name: Joi.string().required(),
- keys: Joi.array().items(Joi.link('...').maxRecursion(10)),
+ name: Joi.string().required(),
+ keys: Joi.array().items(Joi.link('...').maxRecursion(10)),
});
```
@@ -2242,8 +2242,8 @@ const schema = Joi.number().greater(5);
```js
const schema = Joi.object({
- min: Joi.number().required(),
- max: Joi.number().greater(Joi.ref('min')).required(),
+ min: Joi.number().required(),
+ max: Joi.number().greater(Joi.ref('min')).required(),
});
```
@@ -2269,8 +2269,8 @@ const schema = Joi.number().less(10);
```js
const schema = Joi.object({
- min: Joi.number().less(Joi.ref('max')).required(),
- max: Joi.number().required(),
+ min: Joi.number().less(Joi.ref('max')).required(),
+ max: Joi.number().required(),
});
```
@@ -2288,8 +2288,8 @@ const schema = Joi.number().max(10);
```js
const schema = Joi.object({
- min: Joi.number().max(Joi.ref('max')).required(),
- max: Joi.number().required(),
+ min: Joi.number().max(Joi.ref('max')).required(),
+ max: Joi.number().required(),
});
```
@@ -2307,8 +2307,8 @@ const schema = Joi.number().min(2);
```js
const schema = Joi.object({
- min: Joi.number().required(),
- max: Joi.number().min(Joi.ref('min')).required(),
+ min: Joi.number().required(),
+ max: Joi.number().min(Joi.ref('min')).required(),
});
```
@@ -2405,8 +2405,8 @@ Supports the same methods of the [`any()`](#any) type.
```js
const object = Joi.object({
- a: Joi.number().min(1).max(10).integer(),
- b: 'some string',
+ a: Joi.number().min(1).max(10).integer(),
+ b: 'some string',
});
await object.validateAsync({ a: 5 });
@@ -2428,13 +2428,13 @@ them are required as well where:
- `peers` - the string key names of which if one present, all are required.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).and('a', 'b');
```
@@ -2449,11 +2449,11 @@ Appends the allowed object keys where:
```js
// Validate key a
const base = Joi.object({
- a: Joi.number(),
+ a: Joi.number(),
});
// Validate keys a, b.
const extended = base.append({
- b: Joi.string(),
+ b: Joi.string(),
});
```
@@ -2468,13 +2468,13 @@ Verifies an assertion where:
```js
const schema = Joi.object({
- a: {
- b: Joi.string(),
- c: Joi.number(),
- },
- d: {
- e: Joi.any(),
- },
+ a: {
+ b: Joi.string(),
+ c: Joi.number(),
+ },
+ d: {
+ e: Joi.any(),
+ },
}).assert('.d.e', Joi.ref('a.c'), 'equal to a.c');
```
@@ -2504,12 +2504,12 @@ Sets or extends the allowed object keys where:
```js
const base = Joi.object().keys({
- a: Joi.number(),
- b: Joi.string(),
+ a: Joi.number(),
+ b: Joi.string(),
});
// Validate keys a, b and c.
const extended = base.keys({
- c: Joi.boolean(),
+ c: Joi.boolean(),
});
```
@@ -2557,13 +2557,13 @@ Defines a relationship between keys where not all peers can be present at the sa
- `peers` - the key names of which if one present, the others may not all be present.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).nand('a', 'b');
```
@@ -2576,13 +2576,13 @@ allowed) where:
- `peers` - the key names of which at least one must appear.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).or('a', 'b');
```
@@ -2595,13 +2595,13 @@ required where:
- `peers` - the exclusive key names that must not appear together but where none are required.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).oxor('a', 'b');
```
@@ -2614,20 +2614,20 @@ Specify validation rules for unknown keys matching a pattern where:
- `pattern` - a pattern that can be either a regular expression or a **joi** schema that will be tested against the unknown key names. Note that if the pattern is a regular expression, for it to match the entire key name, it must begin with `^` and end with `$`.
- `schema` - the schema object matching keys must validate against.
- `options` - options settings:
- - `fallthrough` - if `true`, multiple matching patterns are tested against the key, otherwise once a pattern match is found, no other patterns are compared. Defaults to `false`.
- - `matches` - a joi array schema used to validated the array of matching keys. For example, `Joi.object().pattern(/\d/, Joi.boolean(), { matches: Joi.array().length(2) })` will require two matching keys. If the `matches` schema is not an array type schema, it will be converted to `Joi.array().items(matches)`. If the `matches` schema contains references, they are resolved against the ancestors as follows:
- - self - the array of matching keys (`Joi.ref('.length')`)
- - parent - the object value containing the keys (`Joi.ref('a')`)
+ - `fallthrough` - if `true`, multiple matching patterns are tested against the key, otherwise once a pattern match is found, no other patterns are compared. Defaults to `false`.
+ - `matches` - a joi array schema used to validated the array of matching keys. For example, `Joi.object().pattern(/\d/, Joi.boolean(), { matches: Joi.array().length(2) })` will require two matching keys. If the `matches` schema is not an array type schema, it will be converted to `Joi.array().items(matches)`. If the `matches` schema contains references, they are resolved against the ancestors as follows:
+ - self - the array of matching keys (`Joi.ref('.length')`)
+ - parent - the object value containing the keys (`Joi.ref('a')`)
```js
const schema = Joi.object({
- a: Joi.string(),
+ a: Joi.string(),
}).pattern(/\w\d/, Joi.boolean());
// OR
const schema = Joi.object({
- a: Joi.string(),
+ a: Joi.string(),
}).pattern(Joi.string().min(2).max(5), Joi.boolean());
```
@@ -2660,16 +2660,16 @@ Renames a key to another name (deletes the renamed key) where:
- `from` - the original key name or a regular expression matching keys.
- `to` - the new key name. `to` can be set to a [`template`](#templatetemplate-options) which is rendered at runtime using the current value, global context, and local context if `from` is a regular expression (e.g. the expression `/^(\d+)$/` will match any all-digits keys with a capture group that is accessible in the template via `{#1}`).
- `options` - an optional object with the following optional keys:
- - `alias` - if `true`, does not delete the old key name, keeping both the new and old keys in place. Defaults to `false`.
- - `multiple` - if `true`, allows renaming multiple keys to the same destination where the last rename wins. Defaults to `false`.
- - `override` - if `true`, allows renaming a key over an existing key. Defaults to `false`.
- - `ignoreUndefined` - if `true`, skip renaming of a key if it's undefined. Defaults to `false`.
+ - `alias` - if `true`, does not delete the old key name, keeping both the new and old keys in place. Defaults to `false`.
+ - `multiple` - if `true`, allows renaming multiple keys to the same destination where the last rename wins. Defaults to `false`.
+ - `override` - if `true`, allows renaming a key over an existing key. Defaults to `false`.
+ - `ignoreUndefined` - if `true`, skip renaming of a key if it's undefined. Defaults to `false`.
Keys are renamed before any other validation rules are applied. If `to` is a template that references the object own keys (e.g. `'{.prefix}-{#1}'`), the value of these keys is the raw input value, not the value generated after validation. If a key is renamed and then its value fails to pass a validation rule, the error message will use the renamed key, not the original key which may be confusing for users (labels can help in some cases).
```js
const object = Joi.object({
- a: Joi.number(),
+ a: Joi.number(),
}).rename('b', 'a');
await object.validateAsync({ b: 5 });
@@ -2681,7 +2681,7 @@ Using a regular expression:
const regex = /^foobar$/i;
const schema = Joi.object({
- fooBar: Joi.string(),
+ fooBar: Joi.string(),
}).rename(regex, 'fooBar');
await schema.validateAsync({ FooBar: 'a' });
@@ -2691,14 +2691,14 @@ Using a regular expression with template:
```js
const schema = Joi.object()
- .rename(/^(\d+)$/, Joi.expression('x{#1}x'))
- .pattern(/^x\d+x$/, Joi.any());
+ .rename(/^(\d+)$/, Joi.expression('x{#1}x'))
+ .pattern(/^x\d+x$/, Joi.any());
const input = {
- 123: 'x',
- 1: 'y',
- 0: 'z',
- x4x: 'test',
+ 123: 'x',
+ 1: 'y',
+ 0: 'z',
+ x4x: 'test',
};
const value = await Joi.compile(schema).validateAsync(input);
@@ -2739,16 +2739,16 @@ Requires the presence of other keys whenever the specified key is present where:
- `peers` - the required peer key names that must appear together with `key`. `peers` can be a
single string value or an array of string values.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
Note that unlike [`object.and()`](#objectandpeers-options), `with()` creates a dependency only between the `key` and each of the `peers`, not
between the `peers` themselves.
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).with('a', 'b');
```
@@ -2762,13 +2762,13 @@ Forbids the presence of other keys whenever the specified is present where:
- `peers` - the forbidden peer key names that must not appear together with `key`. `peers` can be a
single string value or an array of string values.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).without('a', ['b']);
```
@@ -2781,13 +2781,13 @@ the same time where:
- `peers` - the exclusive key names that must not appear together but where one of them is required.
- `options` - optional settings:
- - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
- - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
+ - `separator` - overrides the default `.` hierarchy separator. Set to `false` to treat the `key` as a literal value.
+ - `isPresent` - function that overrides the default check for an empty value. Default: `(resolved) => resolved !== undefined`
```js
const schema = Joi.object({
- a: Joi.any(),
- b: Joi.any(),
+ a: Joi.any(),
+ b: Joi.any(),
}).xor('a', 'b');
```
@@ -2832,8 +2832,8 @@ Possible validation errors: [`string.alphanum`](#stringalphanum-1)
Requires the string value to be a valid base64 string; does not check the decoded value.
- `options` - optional settings:
- - `paddingRequired` - if `true`, the string must be properly padded with the `=` characters. Defaults to `true`.
- - `urlSafe` - if `true`, uses the URI-safe base64 format which replaces `+` with `-` and `\` with `_`. Defaults to `false`.
+ - `paddingRequired` - if `true`, the string must be properly padded with the `=` characters. Defaults to `true`.
+ - `urlSafe` - if `true`, uses the URI-safe base64 format which replaces `+` with `-` and `\` with `_`. Defaults to `false`.
Padding characters are not required for decoding, as the number of missing bytes can be inferred from the number of digits. With that said, try to use padding if at all possible.
@@ -2881,7 +2881,7 @@ Possible validation errors: [`string.creditCard`](#stringcreditcard-1)
Requires the string value to be a valid data URI string.
- `options` - optional settings:
- - `paddingRequired` - optional parameter defaulting to `true` which will require `=` padding if `true` or make padding optional if `false`.
+ - `paddingRequired` - optional parameter defaulting to `true` which will require `=` padding if `true` or make padding optional if `false`.
```js
const schema = Joi.string().dataUri();
@@ -2896,22 +2896,22 @@ Possible validation errors: [`string.dataUri`](#stringdatauri)
Requires the string value to be a valid domain name.
- `options` - optional settings:
- - `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
- - `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
- - `allowUnderscore` - if `true`, underscores (`_`) are allowed in the domain name. Defaults to `false`.
- - `minDomainSegments` - number of segments required for the domain. Defaults to `2`.
- - `maxDomainSegments` - maximum number of allowed domain segments. Default to no limit.
- - `tlds` - options for TLD (top level domain) validation. By default, the TLD must be a valid
- name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt). To
- disable validation, set `tlds` to `false`. To customize how TLDs are validated, set one of
- these:
- - `allow` - one of:
- - `true` to use the IANA list of registered TLDs. This is the default value.
- - `false` to allow any TLD not listed in the `deny` list, if present.
- - a `Set` or array of the allowed TLDs. Cannot be used together with `deny`.
- - `deny` - one of:
- - a `Set` or array of the forbidden TLDs. Cannot be used together with a custom `allow`
- list.
+ - `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
+ - `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
+ - `allowUnderscore` - if `true`, underscores (`_`) are allowed in the domain name. Defaults to `false`.
+ - `minDomainSegments` - number of segments required for the domain. Defaults to `2`.
+ - `maxDomainSegments` - maximum number of allowed domain segments. Default to no limit.
+ - `tlds` - options for TLD (top level domain) validation. By default, the TLD must be a valid
+ name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt). To
+ disable validation, set `tlds` to `false`. To customize how TLDs are validated, set one of
+ these:
+ - `allow` - one of:
+ - `true` to use the IANA list of registered TLDs. This is the default value.
+ - `false` to allow any TLD not listed in the `deny` list, if present.
+ - a `Set` or array of the allowed TLDs. Cannot be used together with `deny`.
+ - `deny` - one of:
+ - a `Set` or array of the forbidden TLDs. Cannot be used together with a custom `allow`
+ list.
```js
const schema = Joi.string().domain();
@@ -2924,29 +2924,29 @@ Possible validation errors: [`string.domain`](#stringdomain)
Requires the string value to be a valid email address.
- `options` - optional settings:
- - `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
- - `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
- - `allowUnderscore` - if `true`, underscores (`_`) are allowed in the domain name. Defaults to `false`.
- - `ignoreLength` - if `true`, ignore invalid email length errors. Defaults to `false`.
- - `minDomainSegments` - number of segments required for the domain. The default setting excludes
- single segment domains such as `example@io` which is a valid email but very uncommon. Defaults
- to `2`.
- - `maxDomainSegments` - maximum number of allowed domain segments. Default to no limit.
- - `multiple` - if `true`, allows multiple email addresses in a single string, separated by `,`
- or the `separator` characters. Defaults to `false`.
- - `separator` - when `multiple` is `true`, overrides the default `,` separator. String can be
- a single character or multiple separator characters. Defaults to `','`.
- - `tlds` - options for TLD (top level domain) validation. By default, the TLD must be a valid
- name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt). To
- disable validation, set `tlds` to `false`. To customize how TLDs are validated, set one of
- these:
- - `allow` - one of:
- - `true` to use the IANA list of registered TLDs. This is the default value.
- - `false` to allow any TLD not listed in the `deny` list, if present.
- - a `Set` or array of the allowed TLDs. Cannot be used together with `deny`.
- - `deny` - one of:
- - a `Set` or array of the forbidden TLDs. Cannot be used together with a custom `allow`
- list.
+ - `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
+ - `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
+ - `allowUnderscore` - if `true`, underscores (`_`) are allowed in the domain name. Defaults to `false`.
+ - `ignoreLength` - if `true`, ignore invalid email length errors. Defaults to `false`.
+ - `minDomainSegments` - number of segments required for the domain. The default setting excludes
+ single segment domains such as `example@io` which is a valid email but very uncommon. Defaults
+ to `2`.
+ - `maxDomainSegments` - maximum number of allowed domain segments. Default to no limit.
+ - `multiple` - if `true`, allows multiple email addresses in a single string, separated by `,`
+ or the `separator` characters. Defaults to `false`.
+ - `separator` - when `multiple` is `true`, overrides the default `,` separator. String can be
+ a single character or multiple separator characters. Defaults to `','`.
+ - `tlds` - options for TLD (top level domain) validation. By default, the TLD must be a valid
+ name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt). To
+ disable validation, set `tlds` to `false`. To customize how TLDs are validated, set one of
+ these:
+ - `allow` - one of:
+ - `true` to use the IANA list of registered TLDs. This is the default value.
+ - `false` to allow any TLD not listed in the `deny` list, if present.
+ - a `Set` or array of the allowed TLDs. Cannot be used together with `deny`.
+ - `deny` - one of:
+ - a `Set` or array of the forbidden TLDs. Cannot be used together with a custom `allow`
+ list.
```js
const schema = Joi.string().email();
@@ -2961,25 +2961,25 @@ Possible validation errors: [`string.email`](#stringemail)
Requires the string value to be a valid GUID.
- `options` - optional settings:
- - `version` - specifies one or more acceptable versions. Can be an Array or String with the following values:
- `uuidv1`, `uuidv2`, `uuidv3`, `uuidv4`, `uuidv5`, `uuidv6`, `uuidv7` or `uuidv8`. If no `version` is specified then it is assumed to be a generic `guid`
- which will not validate the version or variant of the guid and just check for general structure format.
- - `separator` - defines the allowed or required GUID separator where:
- - `true` - a separator is required, can be either `:` or `-`.
- - `false` - separator is not allowed.
- - `'-'` - a dash separator is required.
- - `':'` - a colon separator is required.
- - defaults to optional `:` or `-` separator.
- - `wrapper` - defines the allowed or required GUID wrapper characters where:
- - `undefined` - (default) the GUID can be optionally wrapped with `{}`, `[]`, or `()`. The opening and closing characters must be a matching pair.
- - `true` - the GUID must be wrapped with `{}`, `[]`, or `()`. The opening and closing characters must be a matching pair.
- - `false` - wrapper characters are not allowed.
- - `'['`, `'{'`, or `'('` - a specific wrapper is required (e.g., if `wrapper` is `'['`, the GUID must be enclosed in square brackets).
+ - `version` - specifies one or more acceptable versions. Can be an Array or String with the following values:
+ `uuidv1`, `uuidv2`, `uuidv3`, `uuidv4`, `uuidv5`, `uuidv6`, `uuidv7` or `uuidv8`. If no `version` is specified then it is assumed to be a generic `guid`
+ which will not validate the version or variant of the guid and just check for general structure format.
+ - `separator` - defines the allowed or required GUID separator where:
+ - `true` - a separator is required, can be either `:` or `-`.
+ - `false` - separator is not allowed.
+ - `'-'` - a dash separator is required.
+ - `':'` - a colon separator is required.
+ - defaults to optional `:` or `-` separator.
+ - `wrapper` - defines the allowed or required GUID wrapper characters where:
+ - `undefined` - (default) the GUID can be optionally wrapped with `{}`, `[]`, or `()`. The opening and closing characters must be a matching pair.
+ - `true` - the GUID must be wrapped with `{}`, `[]`, or `()`. The opening and closing characters must be a matching pair.
+ - `false` - wrapper characters are not allowed.
+ - `'['`, `'{'`, or `'('` - a specific wrapper is required (e.g., if `wrapper` is `'['`, the GUID must be enclosed in square brackets).
```js
const schema = Joi.string().guid({
- version: ['uuidv4', 'uuidv5'],
- wrapper: false,
+ version: ['uuidv4', 'uuidv5'],
+ wrapper: false,
});
```
@@ -2990,8 +2990,8 @@ Possible validation errors: [`string.guid`](#stringguid)
Requires the string value to be a valid hexadecimal string.
- `options` - optional settings:
- - `byteAligned` - Boolean specifying whether you want to check that the hexadecimal string is byte aligned. If `convert` is `true`, a `0` will be added in front of the string in case it needs to be aligned. Defaults to `false`.
- - `prefix` - Boolean or `optional`. When `true`, the string will be considered valid if prefixed with `0x` or `0X`. When `false`, the prefix is forbidden. When `optional`, the string will be considered valid if prefixed or not prefixed at all. Defaults to `false`.
+ - `byteAligned` - Boolean specifying whether you want to check that the hexadecimal string is byte aligned. If `convert` is `true`, a `0` will be added in front of the string in case it needs to be aligned. Defaults to `false`.
+ - `prefix` - Boolean or `optional`. When `true`, the string will be considered valid if prefixed with `0x` or `0X`. When `false`, the prefix is forbidden. When `optional`, the string will be considered valid if prefixed or not prefixed at all. Defaults to `false`.
```js
const schema = Joi.string().hex({ prefix: 'optional' });
@@ -3022,14 +3022,14 @@ const schema = Joi.string().valid('a').insensitive();
Requires the string value to be a valid ip address.
- `options` - optional settings:
- - `version` - One or more IP address versions to validate against. Valid values: `ipv4`, `ipv6`, `ipvfuture`
- - `cidr` - Used to determine if a CIDR is allowed or not. Valid values: `optional`, `required`, `forbidden`
+ - `version` - One or more IP address versions to validate against. Valid values: `ipv4`, `ipv6`, `ipvfuture`
+ - `cidr` - Used to determine if a CIDR is allowed or not. Valid values: `optional`, `required`, `forbidden`
```js
// Accept only ipv4 and ipv6 addresses with a CIDR
const schema = Joi.string().ip({
- version: ['ipv4', 'ipv6'],
- cidr: 'required',
+ version: ['ipv4', 'ipv6'],
+ cidr: 'required',
});
```
@@ -3079,8 +3079,8 @@ const schema = Joi.string().length(5);
```js
const schema = Joi.object({
- length: Joi.string().required(),
- value: Joi.string().length(Joi.ref('length'), 'utf8').required(),
+ length: Joi.string().required(),
+ value: Joi.string().length(Joi.ref('length'), 'utf8').required(),
});
```
@@ -3110,8 +3110,8 @@ const schema = Joi.string().max(10);
```js
const schema = Joi.object({
- max: Joi.string().required(),
- value: Joi.string().max(Joi.ref('max'), 'utf8').required(),
+ max: Joi.string().required(),
+ value: Joi.string().max(Joi.ref('max'), 'utf8').required(),
});
```
@@ -3130,8 +3130,8 @@ const schema = Joi.string().min(2);
```js
const schema = Joi.object({
- min: Joi.string().required(),
- value: Joi.string().min(Joi.ref('min'), 'utf8').required(),
+ min: Joi.string().required(),
+ value: Joi.string().min(Joi.ref('min'), 'utf8').required(),
});
```
@@ -3161,9 +3161,9 @@ Defines a pattern rule where:
- `regex` - a regular expression object the string value must match against. Note that if the pattern is a regular expression, for it to match the entire key name, it must begin with `^` and end with `$`.
- `name` - optional name for patterns (useful with multiple patterns).
- `options` - an optional configuration object with the following supported properties:
- - `name` - optional pattern name.
- - `invert` - optional boolean flag. Defaults to `false` behavior. If specified as `true`, the
- provided pattern will be disallowed instead of required.
+ - `name` - optional pattern name.
+ - `invert` - optional boolean flag. Defaults to `false` behavior. If specified as `true`, the
+ provided pattern will be disallowed instead of required.
```js
const schema = Joi.string().pattern(/^[abc]+$/);
@@ -3178,8 +3178,8 @@ const invertedSchema = Joi.string().pattern(/^[a-z]+$/, { invert: true });
invertedSchema.validate('lowercase'); // ValidationError: "value" with value "lowercase" matches the inverted pattern: [a-z]
const invertedNamedSchema = Joi.string().pattern(/^[a-z]+$/, {
- name: 'alpha',
- invert: true,
+ name: 'alpha',
+ invert: true,
});
invertedNamedSchema.validate('lowercase'); // ValidationError: "value" with value "lowercase" matches the inverted alpha pattern
```
@@ -3255,17 +3255,17 @@ Possible validation errors: [`string.uppercase`](#stringuppercase-1)
Requires the string value to be a valid [RFC 3986](http://tools.ietf.org/html/rfc3986) URI.
- `options` - optional settings:
- - `scheme` - Specifies one or more acceptable Schemes, should only include the scheme name. Can be an Array or String (strings are automatically escaped for use in a Regular Expression).
- - `allowRelative` - Allow relative URIs. Defaults to `false`.
- - `relativeOnly` - Restrict only relative URIs. Defaults to `false`.
- - `allowQuerySquareBrackets` - Allows unencoded square brackets inside the query string. This is **NOT** RFC 3986 compliant but query strings like `abc[]=123&abc[]=456` are very common these days. Defaults to `false`.
- - `domain` - Validate the domain component using the options specified in [`string.domain()`](#stringdomainoptions).
- - `encodeUri` - When `convert` is true, if the validation fails, attempts to encode the URI using [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) before validating it again. This allows to provide, for example, unicode URIs, and have it encoded for you. Defaults to `false`.
+ - `scheme` - Specifies one or more acceptable Schemes, should only include the scheme name. Can be an Array or String (strings are automatically escaped for use in a Regular Expression).
+ - `allowRelative` - Allow relative URIs. Defaults to `false`.
+ - `relativeOnly` - Restrict only relative URIs. Defaults to `false`.
+ - `allowQuerySquareBrackets` - Allows unencoded square brackets inside the query string. This is **NOT** RFC 3986 compliant but query strings like `abc[]=123&abc[]=456` are very common these days. Defaults to `false`.
+ - `domain` - Validate the domain component using the options specified in [`string.domain()`](#stringdomainoptions).
+ - `encodeUri` - When `convert` is true, if the validation fails, attempts to encode the URI using [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) before validating it again. This allows to provide, for example, unicode URIs, and have it encoded for you. Defaults to `false`.
```js
// Accept git or git http/https
const schema = Joi.string().uri({
- scheme: ['git', /git\+https?/],
+ scheme: ['git', /git\+https?/],
});
```
@@ -3291,14 +3291,14 @@ Possible validation errors: [`symbol.base`](#symbolbase)
Allows values to be transformed into `Symbol`s, where:
- `map` - mapping declaration that can be:
- - an object, where keys are strings, and values are `Symbol`s
- - an array of arrays of length 2, where for each sub-array, the 1st element must be anything but an object, a function or a `Symbol`, and the 2nd element must be a Symbol
- - a `Map`, following the same principles as the array above
+ - an object, where keys are strings, and values are `Symbol`s
+ - an array of arrays of length 2, where for each sub-array, the 1st element must be anything but an object, a function or a `Symbol`, and the 2nd element must be a Symbol
+ - a `Map`, following the same principles as the array above
```js
const schema = Joi.symbol().map([
- [1, Symbol('one')],
- ['two', Symbol('two')],
+ [1, Symbol('one')],
+ ['two', Symbol('two')],
]);
```
@@ -3332,170 +3332,171 @@ Where:
- `base`: The base schema to extend from. This key is forbidden when `type` is a regular expression.
- `messages`: A hash of error codes and their messages. To interpolate dynamic values, use the [template syntax](#template-syntax).
- `flags`: A hash of flag names and their definitions where:
- - `default`: The default value of the flag. When `describe()` is called and the current flag matches this default value, it will be omitted entirely from the description.
+ - `default`: The default value of the flag. When `describe()` is called and the current flag matches this default value, it will be omitted entirely from the description.
- `prepare`: A function with signature `function (value, helpers) {}` that prepares the input value (for example, converts `,` to `.` to support multiple decimal representations) where:
- - `value`: The input value.
- - `helpers`: [Validation helpers](#validation-helpers)
+ - `value`: The input value.
+ - `helpers`: [Validation helpers](#validation-helpers)
- Must return an object with one of the following keys:
- - `value`: The modified value.
- - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
+ Must return an object with one of the following keys:
+ - `value`: The modified value.
+ - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
- If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
+ If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
- `coerce`: A function with signature `function (value, helpers) {}` that coerces the input value where:
- - `value`: The input value.
- - `helpers`: [Validation helpers](#validation-helpers)
-
- You can also pass an object where:
- - `from`: The type(s) to convert from. Can be a single string or an array of strings. Joi will only run `method` if the value `typeof` of the input value is equal to one of the provided values.
- - `method`: A function with signature `function (value, helpers)` that coerces the input value where:
- `value`: The input value.
- `helpers`: [Validation helpers](#validation-helpers)
- Must return an object with one of the following keys:
- - `value`: The modified value.
- - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
+ You can also pass an object where:
+ - `from`: The type(s) to convert from. Can be a single string or an array of strings. Joi will only run `method` if the value `typeof` of the input value is equal to one of the provided values.
+ - `method`: A function with signature `function (value, helpers)` that coerces the input value where:
+ - `value`: The input value.
+ - `helpers`: [Validation helpers](#validation-helpers)
+
+ Must return an object with one of the following keys:
+ - `value`: The modified value.
+ - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
- If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
+ If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
- `validate`: A function with signature `function (value, helpers) {}` that performs base validation on the input value where:
- - `value`: The input value.
- - `helpers`: [Validation helpers](#validation-helpers)
+ - `value`: The input value.
+ - `helpers`: [Validation helpers](#validation-helpers)
- Must return an object with one of the following keys:
- - `value`: The modified value.
- - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
+ Must return an object with one of the following keys:
+ - `value`: The modified value.
+ - `errors`: Validation error(s) generated by `$_createError()` or `helpers.error()`.
- If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
+ If `errors` is defined, validation will abort regardless of `abortEarly`. Refer to the validation process above for further information.
- `jsonSchema`: A function with signature `function (schema, res, mode, options) {}` that returns the JSON Schema for the type where:
- - `schema`: The current schema instance.
- - `res`: The current JSON Schema object.
- - `mode`: Either `'input'` or `'output'`.
- - `options`: The options passed to `jsonSchema.input()` or `jsonSchema.output()`.
-
- Must return the modified JSON Schema object.
-
-- `rules`: A hash of validation rule names and their implementation where:
- - `alias`: Aliases of the rule. Can be a string or an array of strings.
- - `args`: An array of argument names or an object that define the parameters the rule will accept where:
- - `name`: The argument name.
- - `ref`: Whether this argument allows references. Joi will resolve them before passing to `validate`. Defaults to `false`.
- - `assert`: A function of signature `function (value) {}` that validates the argument by returning a boolean. Also accepts a Joi schema. This key is required if `ref` is set to `true`.
- - `normalize`: A function of signature `function (value) {}` that normalizes the argument before passing it to `assert`.
- - `message`: A message to throw if `assert` is a function. This key is forbidden if `assert` is a schema.
- - `convert`: Whether this is a dual rule that converts the input value and validates it at the same time. Defaults to `false`.
- - `manifest`: Whether this rule should be outputted in the schema's description. Defaults to `true`.
- - `method`: The method that will be attached onto the schema instance. Useful when you need to set flags. If set to `undefined`, Joi will default to a function that when called will add the rule to the rules queue. If set to `false`, the no method will be added to the instance.
- - `multi`: Whether this rule can be invoked multiple times. Defaults to `false`.
- - `validate`: A function of signature `function (value, helpers, args, rule)` that validates the input value where:
- - `value`: The input value.
- - `helpers`: [Validation helpers](#validation-helpers)
- - `args`: Resolved and validated arguments mapped by their names.
- - `rule`: The rule definitions passed to `$_addRule` left untouched. Useful if you need access to the raw arguments before validation.
- - `jsonSchema`: A function with signature `function (rule, res, isOnly, mode, options) {}` that returns the JSON Schema for the rule where:
- - `rule`: The rule object.
+ - `schema`: The current schema instance.
- `res`: The current JSON Schema object.
- - `isOnly`: A boolean indicating if the schema has the `only` flag set.
- `mode`: Either `'input'` or `'output'`.
- `options`: The options passed to `jsonSchema.input()` or `jsonSchema.output()`.
Must return the modified JSON Schema object.
+- `rules`: A hash of validation rule names and their implementation where:
+ - `alias`: Aliases of the rule. Can be a string or an array of strings.
+ - `args`: An array of argument names or an object that define the parameters the rule will accept where:
+ - `name`: The argument name.
+ - `ref`: Whether this argument allows references. Joi will resolve them before passing to `validate`. Defaults to `false`.
+ - `assert`: A function of signature `function (value) {}` that validates the argument by returning a boolean. Also accepts a Joi schema. This key is required if `ref` is set to `true`.
+ - `normalize`: A function of signature `function (value) {}` that normalizes the argument before passing it to `assert`.
+ - `message`: A message to throw if `assert` is a function. This key is forbidden if `assert` is a schema.
+ - `convert`: Whether this is a dual rule that converts the input value and validates it at the same time. Defaults to `false`.
+ - `manifest`: Whether this rule should be outputted in the schema's description. Defaults to `true`.
+ - `method`: The method that will be attached onto the schema instance. Useful when you need to set flags. If set to `undefined`, Joi will default to a function that when called will add the rule to the rules queue. If set to `false`, the no method will be added to the instance.
+ - `multi`: Whether this rule can be invoked multiple times. Defaults to `false`.
+ - `validate`: A function of signature `function (value, helpers, args, rule)` that validates the input value where:
+ - `value`: The input value.
+ - `helpers`: [Validation helpers](#validation-helpers)
+ - `args`: Resolved and validated arguments mapped by their names.
+ - `rule`: The rule definitions passed to `$_addRule` left untouched. Useful if you need access to the raw arguments before validation.
+ - `jsonSchema`: A function with signature `function (rule, res, isOnly, mode, options) {}` that returns the JSON Schema for the rule where:
+ - `rule`: The rule object.
+ - `res`: The current JSON Schema object.
+ - `isOnly`: A boolean indicating if the schema has the `only` flag set.
+ - `mode`: Either `'input'` or `'output'`.
+ - `options`: The options passed to `jsonSchema.input()` or `jsonSchema.output()`.
+
+ Must return the modified JSON Schema object.
+
- `overrides`: A hash of method names and their overridden implementation. To refer to the parent method, use [`$_parent()`](#\_parentmethod-args)
```js
const Joi = require('joi');
const custom = Joi.extend((joi) => {
- return {
- type: 'million',
- base: joi.number(),
- messages: {
- 'million.base': '{{#label}} must be at least a million',
- 'million.big': '{{#label}} must be at least five millions',
- 'million.round': '{{#label}} must be a round number',
- 'million.dividable': '{{#label}} must be dividable by {{#q}}',
- },
- coerce(value, helpers) {
- // Only called when prefs.convert is true
-
- if (helpers.schema.$_getRule('round')) {
- return { value: Math.round(value) };
- }
- },
- validate(value, helpers) {
- // Base validation regardless of the rules applied
-
- if (value < 1000000) {
- return { value, errors: helpers.error('million.base') };
- }
-
- // Check flags for global state
-
- if (helpers.schema.$_getFlag('big') && value < 5000000) {
- return { value, errors: helpers.error('million.big') };
- }
- },
- rules: {
- big: {
- alias: 'large',
- method() {
- return this.$_setFlag('big', true);
+ return {
+ type: 'million',
+ base: joi.number(),
+ messages: {
+ 'million.base': '{{#label}} must be at least a million',
+ 'million.big': '{{#label}} must be at least five millions',
+ 'million.round': '{{#label}} must be a round number',
+ 'million.dividable': '{{#label}} must be dividable by {{#q}}',
},
- },
- round: {
- convert: true, // Dual rule: converts or validates
- method() {
- return this.$_addRule('round');
- },
- validate(value, helpers, args, options) {
- // Only called when prefs.convert is false (due to rule convert option)
+ coerce(value, helpers) {
+ // Only called when prefs.convert is true
- if (value % 1 !== 0) {
- return helpers.error('million.round');
- }
- },
- },
- dividable: {
- multi: true, // Rule supports multiple invocations
- method(q) {
- return this.$_addRule({ name: 'dividable', args: { q } });
+ if (helpers.schema.$_getRule('round')) {
+ return { value: Math.round(value) };
+ }
},
- args: [
- {
- name: 'q',
- ref: true,
- assert: (value) => typeof value === 'number' && !isNaN(value),
- message: 'must be a number',
- },
- ],
- validate(value, helpers, args, options) {
- if (value % args.q === 0) {
- return value; // Value is valid
- }
+ validate(value, helpers) {
+ // Base validation regardless of the rules applied
- return helpers.error('million.dividable', { q: args.q });
- },
- },
- even: {
- method() {
- // Rule with only method used to alias another rule
+ if (value < 1000000) {
+ return { value, errors: helpers.error('million.base') };
+ }
+
+ // Check flags for global state
- return this.dividable(2);
+ if (helpers.schema.$_getFlag('big') && value < 5000000) {
+ return { value, errors: helpers.error('million.big') };
+ }
},
- },
- },
- };
+ rules: {
+ big: {
+ alias: 'large',
+ method() {
+ return this.$_setFlag('big', true);
+ },
+ },
+ round: {
+ convert: true, // Dual rule: converts or validates
+ method() {
+ return this.$_addRule('round');
+ },
+ validate(value, helpers, args, options) {
+ // Only called when prefs.convert is false (due to rule convert option)
+
+ if (value % 1 !== 0) {
+ return helpers.error('million.round');
+ }
+ },
+ },
+ dividable: {
+ multi: true, // Rule supports multiple invocations
+ method(q) {
+ return this.$_addRule({ name: 'dividable', args: { q } });
+ },
+ args: [
+ {
+ name: 'q',
+ ref: true,
+ assert: (value) =>
+ typeof value === 'number' && !isNaN(value),
+ message: 'must be a number',
+ },
+ ],
+ validate(value, helpers, args, options) {
+ if (value % args.q === 0) {
+ return value; // Value is valid
+ }
+
+ return helpers.error('million.dividable', { q: args.q });
+ },
+ },
+ even: {
+ method() {
+ // Rule with only method used to alias another rule
+
+ return this.dividable(2);
+ },
+ },
+ },
+ };
});
const schema = custom.object({
- a: custom.million().round().dividable(Joi.ref('b')),
- b: custom.number(),
- c: custom.million().even().dividable(7),
- d: custom.million().round().prefs({ convert: false }),
- e: custom.million().large(),
+ a: custom.million().round().dividable(Joi.ref('b')),
+ b: custom.number(),
+ c: custom.million().even().dividable(7),
+ d: custom.million().round().prefs({ convert: false }),
+ e: custom.million().large(),
});
```
@@ -3506,9 +3507,9 @@ const schema = custom.object({
- `schema`: The reference to the current schema. Useful if you need to use any of the [Advanced functions](#advanced-functions).
- `state`: The current validation state. See [Validation state](#validation-state).
- `error`: A function with signature `function (code, local, localState = currentState) {}` similar to [`$_createError()`](#\_createerrorcode-value-local-state-prefs-options) but with the current value, validation options, current state passed where:
- - `code`: The error code.
- - `local`: Local context used to interpolate the message.
- - `localState`: The localized state.
+ - `code`: The error code.
+ - `local`: Local context used to interpolate the message.
+ - `localState`: The localized state.
- `errorsArray`: A function that creates an array that can be recognised by Joi as a valid error array. **Note that using a native JS array can cause Joi to output incorrect results.**
- `warn`: TODO
- `message`: TODO
@@ -3549,10 +3550,10 @@ TODO
Adds a rule to the rules queue where:
- `options`: A rule name string or rule options where:
- - `name`: The name of the rule.
- - `args`: The arguments to be processed.
- - `method`: The name of another rule to reuse.
- You can also pass extra properties and they will be accessible within the `rule` argument of the `validate` method.
+ - `name`: The name of the rule.
+ - `args`: The arguments to be processed.
+ - `method`: The name of another rule to reuse.
+ You can also pass extra properties and they will be accessible within the `rule` argument of the `validate` method.
#### $\_compile(schema, options)
@@ -3619,7 +3620,7 @@ Sets a flag where:
- `name`: The flag name to set.
- `value`: The value to set the flag to.
- `options`: Optional options where:
- - `clone`: Whether to clone the schema. Defaults to `true`. Only set to `false` if the schema has already been cloned before.
+ - `clone`: Whether to clone the schema. Defaults to `true`. Only set to `false` if the schema has already been cloned before.
#### $\_validate(value, state, prefs)
@@ -3640,14 +3641,14 @@ Performs validation against the current schema without the extra overhead of mer
- `name` - `'ValidationError'`.
- `isJoi` - `true`.
- `details` - an array of errors :
- - `message` - string with a description of the error.
- - `path` - ordered array where each element is the accessor to the value where the error happened.
- - `type` - type of the error.
- - `context` - object providing context of the error containing:
- - `key` - key of the value that erred, equivalent to the last element of `details.path`.
- - `label` - label of the value that erred, or the `key` if any, or the default `messages.root`.
- - `value` - the value that failed validation.
- - other error specific properties as described for each error code.
+ - `message` - string with a description of the error.
+ - `path` - ordered array where each element is the accessor to the value where the error happened.
+ - `type` - type of the error.
+ - `context` - object providing context of the error containing:
+ - `key` - key of the value that erred, equivalent to the last element of `details.path`.
+ - `label` - label of the value that erred, or the `key` if any, or the default `messages.root`.
+ - `value` - the value that failed validation.
+ - other error specific properties as described for each error code.
- `annotate()` - function that returns a string with an annotated version of the object pointing at
the places where errors occurred. Takes an optional parameter that, if truthy, will strip the
colors out of the output.
@@ -3687,7 +3688,7 @@ Additional local context properties:
```ts
{
- types: Array; // The list of expected types
+ types: Array; // The list of expected types
}
```
@@ -3699,7 +3700,7 @@ Additional local context properties:
```ts
{
- error: Error; // The error thrown
+ error: Error; // The error thrown
}
```
@@ -3711,7 +3712,7 @@ Additional local context properties:
```ts
{
- error: Error; // Error generated during the default value function call
+ error: Error; // Error generated during the default value function call
}
```
@@ -3723,7 +3724,7 @@ Additional local context properties:
```ts
{
- error: Error; // Error generated during the failover value function call
+ error: Error; // Error generated during the failover value function call
}
```
@@ -3735,7 +3736,7 @@ Additional local context properties:
```ts
{
- invalids: Array; // Contains the list of the invalid values that should be rejected
+ invalids: Array; // Contains the list of the invalid values that should be rejected
}
```
@@ -3747,7 +3748,7 @@ Additional local context properties:
```ts
{
- valids: Array; // Contains the list of the valid values that were expected
+ valids: Array; // Contains the list of the valid values that were expected
}
```
@@ -3785,7 +3786,7 @@ Additional local context properties:
```ts
{
- pos: number; // Index where the value was found in the array
+ pos: number; // Index where the value was found in the array
}
```
@@ -3810,7 +3811,7 @@ Additional local context properties:
```ts
{
- knownMisses: Array; // Labels of all the missing values
+ knownMisses: Array; // Labels of all the missing values
}
```
@@ -3822,7 +3823,7 @@ Additional local context properties:
```ts
{
- unknownMisses: number; // Count of missing values that didn't have a label
+ unknownMisses: number; // Count of missing values that didn't have a label
}
```
@@ -3834,7 +3835,7 @@ Additional local context properties:
```ts
{
- pos: number; // Index where the value was found in the array
+ pos: number; // Index where the value was found in the array
}
```
@@ -3846,7 +3847,7 @@ Additional local context properties:
```ts
{
- limit: number; // Length that was expected for this array
+ limit: number; // Length that was expected for this array
}
```
@@ -3858,7 +3859,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum length that was expected for this array
+ limit: number; // Maximum length that was expected for this array
}
```
@@ -3870,7 +3871,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum length that was expected for this array
+ limit: number; // Minimum length that was expected for this array
}
```
@@ -3912,7 +3913,7 @@ Additional local context properties:
```ts
{
- type: string; // The unsupported array item type
+ type: string; // The unsupported array item type
}
```
@@ -3924,7 +3925,7 @@ Additional local context properties:
```ts
{
- pos: number; // Index where an undefined value was found in the array
+ pos: number; // Index where an undefined value was found in the array
}
```
@@ -3950,7 +3951,7 @@ Additional local context properties:
```ts
{
- patternLabel: string; // Label of assertion schema
+ patternLabel: string; // Label of assertion schema
}
```
@@ -3970,7 +3971,7 @@ Additional local context properties:
```ts
{
- limit: number; // Length that was expected for this buffer
+ limit: number; // Length that was expected for this buffer
}
```
@@ -3982,7 +3983,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum length that was expected for this buffer
+ limit: number; // Maximum length that was expected for this buffer
}
```
@@ -3994,7 +3995,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum length that was expected for this buffer
+ limit: number; // Minimum length that was expected for this buffer
}
```
@@ -4014,7 +4015,7 @@ Additional local context properties:
```ts
{
- format: string; // The required format
+ format: string; // The required format
}
```
@@ -4026,7 +4027,7 @@ Additional local context properties:
```ts
{
- limit: Date; // Maximum date
+ limit: Date; // Maximum date
}
```
@@ -4038,7 +4039,7 @@ Additional local context properties:
```ts
{
- limit: Date; // Minimum date
+ limit: Date; // Minimum date
}
```
@@ -4050,7 +4051,7 @@ Additional local context properties:
```ts
{
- limit: Date; // Maximum date
+ limit: Date; // Maximum date
}
```
@@ -4062,7 +4063,7 @@ Additional local context properties:
```ts
{
- limit: Date; // Minimum date
+ limit: Date; // Minimum date
}
```
@@ -4078,7 +4079,7 @@ Additional local context properties:
```ts
{
- n: number; // Expected arity
+ n: number; // Expected arity
}
```
@@ -4094,7 +4095,7 @@ Additional local context properties:
```ts
{
- n: number; // Maximum expected arity
+ n: number; // Maximum expected arity
}
```
@@ -4106,7 +4107,7 @@ Additional local context properties:
```ts
{
- n: number; // Minimum expected arity
+ n: number; // Minimum expected arity
}
```
@@ -4122,7 +4123,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum number of times the link may be entered
+ limit: number; // Maximum number of times the link may be entered
}
```
@@ -4138,7 +4139,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum value that was expected for this number
+ limit: number; // Minimum value that was expected for this number
}
```
@@ -4158,7 +4159,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum value that was expected for this number
+ limit: number; // Maximum value that was expected for this number
}
```
@@ -4170,7 +4171,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum value that was expected for this number
+ limit: number; // Maximum value that was expected for this number
}
```
@@ -4182,7 +4183,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum value that was expected for this number
+ limit: number; // Minimum value that was expected for this number
}
```
@@ -4194,7 +4195,7 @@ Additional local context properties:
```ts
{
- multiple: number; // The number of which the input is supposed to be a multiple of
+ multiple: number; // The number of which the input is supposed to be a multiple of
}
```
@@ -4218,7 +4219,7 @@ Additional local context properties:
```ts
{
- limit: number; // The precision that it should have had
+ limit: number; // The precision that it should have had
}
```
@@ -4234,7 +4235,7 @@ Additional local context properties:
```ts
{
- child: string; // Property that is unexpected
+ child: string; // Property that is unexpected
}
```
@@ -4274,7 +4275,7 @@ Additional local context properties:
```ts
{
- type: string; // The expected type
+ type: string; // The expected type
}
```
@@ -4286,7 +4287,7 @@ Additional local context properties:
```ts
{
- limit: number; // Number of keys that was expected for this object
+ limit: number; // Number of keys that was expected for this object
}
```
@@ -4298,7 +4299,7 @@ Additional local context properties:
```ts
{
- limit: number; // Maximum number of keys
+ limit: number; // Maximum number of keys
}
```
@@ -4310,7 +4311,7 @@ Additional local context properties:
```ts
{
- limit: number; // Minimum number of keys
+ limit: number; // Minimum number of keys
}
```
@@ -4400,7 +4401,7 @@ Additional local context properties:
```ts
{
- type: string; // The required schema
+ type: string; // The required schema
}
```
@@ -4412,7 +4413,7 @@ Additional local context properties:
```ts
{
- type: string; // Type name the object should have been
+ type: string; // Type name the object should have been
}
```
@@ -4504,7 +4505,7 @@ Additional local context properties:
```ts
{
- invalids: [string]; // Array of invalid emails
+ invalids: [string]; // Array of invalid emails
}
```
@@ -4549,7 +4550,7 @@ Additional local context properties:
```ts
{
- cidr: string; // CIDR used for the validation
+ cidr: string; // CIDR used for the validation
}
```
@@ -4612,7 +4613,7 @@ Additional local context properties:
```ts
{
- form: string; // Normalization form that is expected
+ form: string; // Normalization form that is expected
}
```
@@ -4692,7 +4693,7 @@ Additional local context properties:
```ts
{
- scheme: string; // Scheme prefix that is expected in the URI
+ scheme: string; // Scheme prefix that is expected in the URI
}
```
diff --git a/generated/markdown/joi/changelog.md b/generated/markdown/joi/changelog.md
index a4673ad..889327c 100644
--- a/generated/markdown/joi/changelog.md
+++ b/generated/markdown/joi/changelog.md
@@ -50,6 +50,10 @@
## Version 17 {#v17}
+### [17.13.4](https://github.com/hapijs/joi/milestone/216) {#17.13.4}
+
+- [#3123](https://github.com/hapijs/joi/pull/3123) chore: backport #3113 to v17
+
### [17.13.3](https://github.com/hapijs/joi/milestone/207) {#17.13.3}
- [#3043](https://github.com/hapijs/joi/pull/3043) fix: correct function type in alternatives error
diff --git a/generated/markdown/policies/styleguide.md b/generated/markdown/policies/styleguide.md
index 1342832..32e264c 100644
--- a/generated/markdown/policies/styleguide.md
+++ b/generated/markdown/policies/styleguide.md
@@ -46,10 +46,10 @@ console.log('even when not required');
- Declare on first use, not at top of function; [self](#prototype-members) being an exception
- Do not chain declarations unless inside `for` parentheses (repeat `const` or `let` for each variable in a separate statement)
- Give descriptive names
- - Do not use similar names or synonyms for different variables unless following a convention
- - `for...in` iterators should use descriptive names
- - `for` iterators should use single character names
- - Use combination of plural for array and singular for each item in the array
+ - Do not use similar names or synonyms for different variables unless following a convention
+ - `for...in` iterators should use descriptive names
+ - `for` iterators should use single character names
+ - Use combination of plural for array and singular for each item in the array
- Use camelCase, never underscores
- Avoid using numbered variables (e.g. i1, i2, i3)
@@ -62,7 +62,7 @@ console.log('even when not required');
// Right
if (condition) {
- return;
+ return;
}
// Wrong
@@ -85,7 +85,7 @@ if (condition) return;
const name = 'john';
for (let i = 0; i < name.length; ++i) {
- console.log(name[i]);
+ console.log(name[i]);
}
// Wrong
@@ -95,7 +95,7 @@ const name = 'john';
const len = name.length;
for (position = 0; position < len; position++) {
- console.log(name[position]);
+ console.log(name[position]);
}
```
@@ -105,8 +105,8 @@ for (position = 0; position < len; position++) {
```javascript
Example.prototype.method = function () {
- this.public = 'external';
- this._private = 'internal';
+ this.public = 'external';
+ this._private = 'internal';
};
```
@@ -114,11 +114,11 @@ Example.prototype.method = function () {
```javascript
Example.prototype.method = function () {
- const self = this;
+ const self = this;
- call(123, function (err) {
- self.display(err);
- });
+ call(123, function (err) {
+ self.display(err);
+ });
};
```
@@ -134,7 +134,7 @@ Example.prototype.method = function () {
const method = function () {};
const arrow = (foo) => {
- return bar;
+ return bar;
};
// Wrong
@@ -164,17 +164,17 @@ Hoek.assert(this instanceof Server, 'Server must be instantiated using new');
// Right
if (test) {
- if (value === 12) {
- console.log('result');
- }
+ if (value === 12) {
+ console.log('result');
+ }
}
// Wrong
if (test) {
- if (value === 12) {
- console.log('result');
- }
+ if (value === 12) {
+ console.log('result');
+ }
}
```
@@ -198,7 +198,7 @@ const string = 'text in single quotes';
```javascript
exports.get = function () {
- // Some code
+ // Some code
};
// 1
// 2
@@ -206,26 +206,26 @@ exports.get = function () {
* jsDoc comment
*/
internals.utility = function () {
- //Some code
+ //Some code
};
```
- Newline after `{` except for inlined or empty objects
- - Inline an object when it improves readability and unlikely to change often
- - No inline object in assignment unless empty
+ - Inline an object when it improves readability and unlikely to change often
+ - No inline object in assignment unless empty
```javascript
// Right
if (condition) {
- execute(value, { strict: true });
+ execute(value, { strict: true });
}
if (condition) {
- const options = {
- strict: true,
- };
- execute(value, options);
+ const options = {
+ strict: true,
+ };
+ execute(value, options);
}
const empty = {};
@@ -233,105 +233,105 @@ const empty = {};
// Wrong
if (condition) {
- execute(value, { strict: true });
+ execute(value, { strict: true });
}
if (condition) {
- const options = { strict: true };
- execute(value, options);
+ const options = { strict: true };
+ execute(value, options);
}
const empty = {};
```
- Newline after `}`
- - Only exception is when followed by `,`, `;`, `);` which must be followed by a newline
- - Includes before `else`, `catch`, etc.
- - Empty line after `}` if not last statement in scope
+ - Only exception is when followed by `,`, `;`, `);` which must be followed by a newline
+ - Includes before `else`, `catch`, etc.
+ - Empty line after `}` if not last statement in scope
```javascript
// Right
if (condition) {
- value = {
- func: () => {
- console.log('example');
- },
- message: 'hello',
- };
-
- execute(value, (err) => {
- console.log(err);
- });
+ value = {
+ func: () => {
+ console.log('example');
+ },
+ message: 'hello',
+ };
+
+ execute(value, (err) => {
+ console.log(err);
+ });
} else {
- console.log('otherwise');
+ console.log('otherwise');
}
// Wrong
if (condition) {
- value = {
- func: () => {
- console.log('example');
- },
- message: 'hello',
- };
- execute(value, (err) => {
- console.log(err);
- });
+ value = {
+ func: () => {
+ console.log('example');
+ },
+ message: 'hello',
+ };
+ execute(value, (err) => {
+ console.log(err);
+ });
} else {
- console.log('otherwise');
+ console.log('otherwise');
}
```
- Empty line after `{`
- - Following a multi-line condition
- - In function scope declarations
- - In arrow function declarations using curly braces
+ - Following a multi-line condition
+ - In function scope declarations
+ - In arrow function declarations using curly braces
```javascript
// Right
exports.method = function () {
- if (condition) {
- if (otherCondition) {
- console.log('sometimes');
- }
+ if (condition) {
+ if (otherCondition) {
+ console.log('sometimes');
+ }
- if (result && result.statusCode === 200) {
- console.log('special case');
- }
+ if (result && result.statusCode === 200) {
+ console.log('special case');
+ }
- console.log('always');
- }
+ console.log('always');
+ }
- execute(123, (err) => {
- console.log(err);
- });
+ execute(123, (err) => {
+ console.log(err);
+ });
- const empty = {};
+ const empty = {};
};
// Wrong
exports.method = function () {
- if (condition) {
- if (otherCondition) {
- console.log('sometimes');
- }
+ if (condition) {
+ if (otherCondition) {
+ console.log('sometimes');
+ }
- if (result && result.statusCode === 200) {
- console.log('special case');
- }
+ if (result && result.statusCode === 200) {
+ console.log('special case');
+ }
- console.log('always');
- }
+ console.log('always');
+ }
- execute(123, (err) => {
- console.log(err);
- });
+ execute(123, (err) => {
+ console.log(err);
+ });
- const empty = {};
+ const empty = {};
};
```
@@ -341,17 +341,17 @@ exports.method = function () {
// Right
if (condition) {
- if (otherCondition) {
- console.log('done');
- }
+ if (otherCondition) {
+ console.log('done');
+ }
}
// Wrong
if (condition) {
- if (otherCondition) {
- console.log('done');
- }
+ if (otherCondition) {
+ console.log('done');
+ }
}
```
@@ -373,13 +373,13 @@ const value = calculate(1, 3);
// Right
const example = function () {
- return value;
+ return value;
};
// Wrong
const example = function () {
- return value;
+ return value;
};
```
@@ -403,7 +403,7 @@ const key = example();
execute('order', 34);
if (result === 'ok') {
- console.log('success');
+ console.log('success');
}
// Wrong
@@ -411,7 +411,7 @@ if (result === 'ok') {
execute('order', 34);
if (result === 'ok') {
- console.log('success');
+ console.log('success');
}
```
@@ -421,17 +421,17 @@ if (result === 'ok') {
// Right
const obj = {
- a: 1,
- b: 2,
- c: 3,
+ a: 1,
+ b: 2,
+ c: 3,
};
// Wrong
const obj = {
- a: 1,
- b: 2,
- c: 3,
+ a: 1,
+ b: 2,
+ c: 3,
};
```
@@ -443,7 +443,7 @@ const obj = {
const name = 'john';
for (let i = 0; i < name.length; ++i) {
- console.log(name[i]);
+ console.log(name[i]);
}
// Wrong
@@ -451,7 +451,7 @@ for (let i = 0; i < name.length; ++i) {
const name = 'john';
for (let i = 0; i < name.length; ++i) {
- console.log(name[i]);
+ console.log(name[i]);
}
```
@@ -461,23 +461,23 @@ for (let i = 0; i < name.length; ++i) {
// Right
for (let book in books) {
- if (books.hasOwnProperty(book)) {
- console.log(book.name);
- }
+ if (books.hasOwnProperty(book)) {
+ console.log(book.name);
+ }
}
// Wrong
for (let book in books) {
- if (books.hasOwnProperty(book)) {
- console.log(book.name);
- }
+ if (books.hasOwnProperty(book)) {
+ console.log(book.name);
+ }
}
```
- Always space after `{` and before `}` in inlined object
- - No space for empty objects `{}`
- - One space for empty functions `{ }`
+ - No space for empty objects `{}`
+ - One space for empty functions `{ }`
```javascript
// Right
@@ -522,7 +522,7 @@ const numbers = [1, 2, 3];
execute({ name: 'john', email: 'john@example.com' });
for (let i = 0; i < name.length; ++i) {
- console.log(name[i]);
+ console.log(name[i]);
}
// Wrong
@@ -532,7 +532,7 @@ execute({ name: 'john', email: 'john@example.com' });
// This for loop violates the style guide, but illustrates incorrect spacing around a comma
for (let i = 0, il = name.length; i < il; ++i) {
- console.log(name[i]);
+ console.log(name[i]);
}
```
@@ -572,7 +572,7 @@ execute('some error message', 12345, this);
const message = 'Hello ' + 'Steve, ' + 'How are you?';
if (value === 'hello' && result === 'ok') {
- console.log('yes');
+ console.log('yes');
}
// Wrong
@@ -580,7 +580,7 @@ if (value === 'hello' && result === 'ok') {
const message = 'Hello ' + 'Steve, ' + 'How are you?';
if (value === 'hello' && result === 'ok') {
- console.log('yes');
+ console.log('yes');
}
```
@@ -612,54 +612,54 @@ const message = foo === bar ? foo : bar;
- No TODOs
- Line
- - Provides narrative for the following single code line (or single statement broken for readability)
- - One line of comment only
- - One empty line before and none after the comment line
- - No empty line before when following `{` unless other rules require it
+ - Provides narrative for the following single code line (or single statement broken for readability)
+ - One line of comment only
+ - One empty line before and none after the comment line
+ - No empty line before when following `{` unless other rules require it
```javascript
function execute() {
- // Initialize state
- const position = 0;
+ // Initialize state
+ const position = 0;
- if (condition) {
- // Return message
- return 'hello';
- }
+ if (condition) {
+ // Return message
+ return 'hello';
+ }
}
```
- Segment
- - Provides narrative for the following code section (one or more lines of code, with or without line breaks)
- - One or more lines of comments
- - One empty line before and one after comments block
+ - Provides narrative for the following code section (one or more lines of code, with or without line breaks)
+ - One or more lines of comments
+ - One empty line before and one after comments block
```javascript
function execute() {
- // Print each book's name
+ // Print each book's name
- for (let book in books) {
- // Check for valid properties
+ for (let book in books) {
+ // Check for valid properties
- if (books.hasOwnProperty(book)) {
- console.log(book.name);
+ if (books.hasOwnProperty(book)) {
+ console.log(book.name);
+ }
}
- }
}
```
- Note
- - Explains the behaviour of a single code statement (can be broken into multiple lines)
- - Used to document unexpected behaviour or non-standard practice
- - Appears immediately at the end of the line (or statement) it describes, following whitespace to separate it from code block
+ - Explains the behaviour of a single code statement (can be broken into multiple lines)
+ - Used to document unexpected behaviour or non-standard practice
+ - Appears immediately at the end of the line (or statement) it describes, following whitespace to separate it from code block
```javascript
function execute(value) {
- if (value !== null && value !== undefined) {
- // Explicit check as 'value' can be 0
+ if (value !== null && value !== undefined) {
+ // Explicit check as 'value' can be 0
- console.log(value);
- }
+ console.log(value);
+ }
}
```
@@ -674,7 +674,7 @@ function execute(value) {
```javascript
if (result && result.status && result.status.statusCode === 200) {
- console.log('success');
+ console.log('success');
}
```
@@ -695,8 +695,8 @@ const message = 'hello' + ' and welcome';
### Module globals
- Every module can only have two top level globals (except for imported modules):
- - `exports` - defined automatically by node
- - `internals` - must be declared as an object at the top of each module immediate following the `require` section
+ - `exports` - defined automatically by node
+ - `internals` - must be declared as an object at the top of each module immediate following the `require` section
- Any variable global to the module must be a property of `internals`, including constants
- If a module has automatically executing code, it must be contained within a function (using the `internals` namespace) and called at the top of the module after the `internals` declaration.
diff --git a/generated/markdown/tlds/changelog.md b/generated/markdown/tlds/changelog.md
index 925390a..d41743b 100644
--- a/generated/markdown/tlds/changelog.md
+++ b/generated/markdown/tlds/changelog.md
@@ -1,5 +1,9 @@
## Version 1 {#v1}
+### [1.1.7](https://github.com/hapijs/tlds/milestone/15) {#1.1.7}
+
+- [#20](https://github.com/hapijs/tlds/pull/20) Update TLDs
+
### [1.1.6](https://github.com/hapijs/tlds/milestone/14) {#1.1.6}
- [#19](https://github.com/hapijs/tlds/pull/19) Update TLDs
diff --git a/generated/metadata/modules.json b/generated/metadata/modules.json
index ea802d2..e541aa5 100644
--- a/generated/metadata/modules.json
+++ b/generated/metadata/modules.json
@@ -1,110 +1,110 @@
{
- "address": {
- "forks": 27,
- "link": "https://github.com/hapijs/address",
- "package": "@hapi/address",
- "slogan": "Validate email address and domain.",
- "stars": 33,
- "updated": "2024-01-29T12:37:22Z",
- "versions": [
- {
- "branch": "v5.1.1",
- "license": "BSD",
- "name": "5.1.1",
- "node": ">= 14"
- }
- ],
- "versionsArray": ["5.1.1"]
- },
- "formula": {
- "forks": 20,
- "link": "https://github.com/hapijs/formula",
- "package": "@hapi/formula",
- "slogan": "Math and string formula parser.",
- "stars": 17,
- "updated": "2024-02-02T16:21:44Z",
- "versions": [
- {
- "branch": "v3.0.2",
- "license": "BSD",
- "name": "3.0.2",
- "node": ">= 14"
- }
- ],
- "versionsArray": ["3.0.2"]
- },
- "joi": {
- "forks": 1509,
- "link": "https://github.com/hapijs/joi",
- "package": "joi",
- "slogan": "The most powerful schema description language and data validator for JavaScript.",
- "stars": 21202,
- "updated": "2026-03-30T17:24:52Z",
- "versions": [
- {
- "branch": "v17.13.3",
- "license": "BSD",
- "name": "17.13.3",
- "node": ">= 14"
- },
- {
- "branch": "v18.2.1",
- "license": "BSD",
- "name": "18.2.1",
- "node": ">= 20"
- }
- ],
- "versionsArray": ["18.2.1", "17.13.3"]
- },
- "joi-date": {
- "forks": 23,
- "link": "https://github.com/hapijs/joi-date",
- "package": "@joi/date",
- "slogan": "Extensions for advance date rules.",
- "stars": 81,
- "updated": "2024-04-22T09:05:34Z",
- "versions": [
- {
- "branch": "v2.1.1",
- "license": "BSD",
- "name": "2.1.1",
- "node": ">= 14"
- }
- ],
- "versionsArray": ["2.1.1"]
- },
- "pinpoint": {
- "forks": 6,
- "link": "https://github.com/hapijs/pinpoint",
- "package": "@hapi/pinpoint",
- "slogan": "Return the filename and line number of the calling function.",
- "stars": 6,
- "updated": "2023-11-12T09:48:56Z",
- "versions": [
- {
- "branch": "v2.0.1",
- "license": "BSD",
- "name": "2.0.1",
- "node": ">= 14"
- }
- ],
- "versionsArray": ["2.0.1"]
- },
- "tlds": {
- "forks": 2,
- "link": "https://github.com/hapijs/tlds",
- "package": "@hapi/tlds",
- "slogan": "TLDS list for domain validation.",
- "stars": 2,
- "updated": "2026-02-17T14:09:37Z",
- "versions": [
- {
- "branch": "v1.1.6",
- "license": "BSD",
- "name": "1.1.6",
- "node": ">= 14"
- }
- ],
- "versionsArray": ["1.1.6"]
- }
+ "address": {
+ "forks": 27,
+ "link": "https://github.com/hapijs/address",
+ "package": "@hapi/address",
+ "slogan": "Validate email address and domain.",
+ "stars": 33,
+ "updated": "2024-01-29T12:37:22Z",
+ "versions": [
+ {
+ "branch": "v5.1.1",
+ "license": "BSD",
+ "name": "5.1.1",
+ "node": ">= 14"
+ }
+ ],
+ "versionsArray": ["5.1.1"]
+ },
+ "formula": {
+ "forks": 20,
+ "link": "https://github.com/hapijs/formula",
+ "package": "@hapi/formula",
+ "slogan": "Math and string formula parser.",
+ "stars": 17,
+ "updated": "2024-02-02T16:21:44Z",
+ "versions": [
+ {
+ "branch": "v3.0.2",
+ "license": "BSD",
+ "name": "3.0.2",
+ "node": ">= 14"
+ }
+ ],
+ "versionsArray": ["3.0.2"]
+ },
+ "joi": {
+ "forks": 1509,
+ "link": "https://github.com/hapijs/joi",
+ "package": "joi",
+ "slogan": "The most powerful schema description language and data validator for JavaScript.",
+ "stars": 21202,
+ "updated": "2026-03-30T17:24:52Z",
+ "versions": [
+ {
+ "branch": "v17.13.4",
+ "license": "BSD",
+ "name": "17.13.4",
+ "node": ">= 14"
+ },
+ {
+ "branch": "v18.2.1",
+ "license": "BSD",
+ "name": "18.2.1",
+ "node": ">= 20"
+ }
+ ],
+ "versionsArray": ["18.2.1", "17.13.4"]
+ },
+ "joi-date": {
+ "forks": 23,
+ "link": "https://github.com/hapijs/joi-date",
+ "package": "@joi/date",
+ "slogan": "Extensions for advance date rules.",
+ "stars": 81,
+ "updated": "2024-04-22T09:05:34Z",
+ "versions": [
+ {
+ "branch": "v2.1.1",
+ "license": "BSD",
+ "name": "2.1.1",
+ "node": ">= 14"
+ }
+ ],
+ "versionsArray": ["2.1.1"]
+ },
+ "pinpoint": {
+ "forks": 6,
+ "link": "https://github.com/hapijs/pinpoint",
+ "package": "@hapi/pinpoint",
+ "slogan": "Return the filename and line number of the calling function.",
+ "stars": 6,
+ "updated": "2023-11-12T09:48:56Z",
+ "versions": [
+ {
+ "branch": "v2.0.1",
+ "license": "BSD",
+ "name": "2.0.1",
+ "node": ">= 14"
+ }
+ ],
+ "versionsArray": ["2.0.1"]
+ },
+ "tlds": {
+ "forks": 2,
+ "link": "https://github.com/hapijs/tlds",
+ "package": "@hapi/tlds",
+ "slogan": "TLDS list for domain validation.",
+ "stars": 2,
+ "updated": "2026-02-17T14:09:37Z",
+ "versions": [
+ {
+ "branch": "v1.1.7",
+ "license": "BSD",
+ "name": "1.1.7",
+ "node": ">= 14"
+ }
+ ],
+ "versionsArray": ["1.1.7"]
+ }
}
diff --git a/generated/modules/address/changelog.json b/generated/modules/address/changelog.json
index fff81df..b77e32e 100644
--- a/generated/modules/address/changelog.json
+++ b/generated/modules/address/changelog.json
@@ -1,429 +1,429 @@
[
- {
- "date": "2023-03-11T10:45:33Z",
- "id": 9146991,
- "issues": [
- {
- "id": 1619963599,
- "labels": [],
- "number": 45,
- "title": "chore: target node 14",
- "url": "https://github.com/hapijs/address/pull/45"
- }
- ],
- "number": 23,
- "url": "https://github.com/hapijs/address/milestone/23",
- "version": "5.1.1"
- },
- {
- "date": "2023-02-18T20:26:49Z",
- "id": 9061974,
- "issues": [
- {
- "id": 1590444869,
- "labels": [],
- "number": 44,
- "title": "chore: change package namespace and upgrade dependencies",
- "url": "https://github.com/hapijs/address/pull/44"
- },
- {
- "id": 1357520760,
- "labels": [],
- "number": 43,
- "title": "feat: add underscore support",
- "url": "https://github.com/hapijs/address/pull/43"
- },
- {
- "id": 1224352951,
- "labels": ["bug"],
- "number": 42,
- "title": "fix: minor improvements to typings and binary conversion",
- "url": "https://github.com/hapijs/address/pull/42"
- }
- ],
- "number": 22,
- "url": "https://github.com/hapijs/address/milestone/22",
- "version": "5.1.0"
- },
- {
- "date": "2022-05-02T05:42:21Z",
- "id": 7793532,
- "issues": [
- {
- "id": 1222504847,
- "labels": ["breaking changes", "feature", "types"],
- "number": 41,
- "title": "Change API",
- "url": "https://github.com/hapijs/address/issues/41"
- },
- {
- "id": 1222504338,
- "labels": ["breaking changes", "feature", "types"],
- "number": 40,
- "title": "Convert to TypeScript",
- "url": "https://github.com/hapijs/address/issues/40"
- },
- {
- "id": 1222245015,
- "labels": ["breaking changes", "dependency"],
- "number": 39,
- "title": "Drop node 12 support",
- "url": "https://github.com/hapijs/address/issues/39"
- },
- {
- "id": 1202218015,
- "labels": ["dependency"],
- "number": 38,
- "title": "Update tlds.js",
- "url": "https://github.com/hapijs/address/pull/38"
- }
- ],
- "number": 20,
- "url": "https://github.com/hapijs/address/milestone/20",
- "version": "5.0.0"
- },
- {
- "date": "2024-01-29T13:21:04Z",
- "id": 10482555,
- "issues": [
- {
- "id": 2105392579,
- "labels": ["bug"],
- "number": 47,
- "title": "chore: update tlds",
- "url": "https://github.com/hapijs/address/pull/47"
- }
- ],
- "number": 24,
- "url": "https://github.com/hapijs/address/milestone/24",
- "version": "4.1.5"
- },
- {
- "date": "2022-03-22T23:22:57Z",
- "id": 7446122,
- "issues": [
- {
- "id": 1173205659,
- "labels": ["dependency"],
- "number": 37,
- "title": "Update the TLDS for email validation",
- "url": "https://github.com/hapijs/address/pull/37"
- }
- ],
- "number": 19,
- "url": "https://github.com/hapijs/address/milestone/19",
- "version": "4.1.4"
- },
- {
- "date": "2021-12-01T08:38:39Z",
- "id": 6735874,
- "issues": [
- {
- "id": 957589243,
- "labels": ["bug"],
- "number": 36,
- "title": "Invalid input error validating link in schema",
- "url": "https://github.com/hapijs/address/issues/36"
- },
- {
- "id": 654430948,
- "labels": ["bug"],
- "number": 31,
- "title": "Incorrect validation",
- "url": "https://github.com/hapijs/address/issues/31"
- }
- ],
- "number": 18,
- "url": "https://github.com/hapijs/address/milestone/18",
- "version": "4.1.3"
- },
- {
- "date": "2021-05-07T06:11:07Z",
- "id": 6403302,
- "issues": [
- {
- "id": 878502441,
- "labels": ["bug"],
- "number": 35,
- "title": "Fails to invalidate URI delimiter chars on domain end",
- "url": "https://github.com/hapijs/address/issues/35"
- }
- ],
- "number": 17,
- "url": "https://github.com/hapijs/address/milestone/17",
- "version": "4.1.2"
- },
- {
- "date": "2021-02-08T01:02:42Z",
- "id": 5619718,
- "issues": [
- {
- "id": 803109463,
- "labels": ["bug"],
- "number": 33,
- "title": "Email validations rejects valid email addresses",
- "url": "https://github.com/hapijs/address/issues/33"
- }
- ],
- "number": 16,
- "url": "https://github.com/hapijs/address/milestone/16",
- "version": "4.1.1"
- },
- {
- "date": "2020-07-06T01:17:17Z",
- "id": 5200674,
- "issues": [
- {
- "id": 651176115,
- "labels": ["feature"],
- "number": 30,
- "title": "Support maxDomainSegments",
- "url": "https://github.com/hapijs/address/issues/30"
- }
- ],
- "number": 15,
- "url": "https://github.com/hapijs/address/milestone/15",
- "version": "4.1.0"
- },
- {
- "date": "2020-03-14T00:01:49Z",
- "id": 4972515,
- "issues": [
- {
- "id": 580941272,
- "labels": ["bug"],
- "number": 26,
- "title": "Capture domain in relative uris",
- "url": "https://github.com/hapijs/address/issues/26"
- }
- ],
- "number": 14,
- "url": "https://github.com/hapijs/address/milestone/14",
- "version": "4.0.1"
- },
- {
- "date": "2020-01-04T08:47:36Z",
- "id": 4972513,
- "issues": [
- {
- "id": 545259529,
- "labels": ["breaking changes", "dependency"],
- "number": 24,
- "title": "Only support node 12",
- "url": "https://github.com/hapijs/address/issues/24"
- }
- ],
- "number": 12,
- "url": "https://github.com/hapijs/address/milestone/12",
- "version": "4.0.0"
- },
- {
- "date": "2020-01-04T08:42:34Z",
- "id": 4852228,
- "issues": [
- {
- "id": 523950264,
- "labels": ["bug"],
+ {
+ "date": "2023-03-11T10:45:33Z",
+ "id": 9146991,
+ "issues": [
+ {
+ "id": 1619963599,
+ "labels": [],
+ "number": 45,
+ "title": "chore: target node 14",
+ "url": "https://github.com/hapijs/address/pull/45"
+ }
+ ],
+ "number": 23,
+ "url": "https://github.com/hapijs/address/milestone/23",
+ "version": "5.1.1"
+ },
+ {
+ "date": "2023-02-18T20:26:49Z",
+ "id": 9061974,
+ "issues": [
+ {
+ "id": 1590444869,
+ "labels": [],
+ "number": 44,
+ "title": "chore: change package namespace and upgrade dependencies",
+ "url": "https://github.com/hapijs/address/pull/44"
+ },
+ {
+ "id": 1357520760,
+ "labels": [],
+ "number": 43,
+ "title": "feat: add underscore support",
+ "url": "https://github.com/hapijs/address/pull/43"
+ },
+ {
+ "id": 1224352951,
+ "labels": ["bug"],
+ "number": 42,
+ "title": "fix: minor improvements to typings and binary conversion",
+ "url": "https://github.com/hapijs/address/pull/42"
+ }
+ ],
+ "number": 22,
+ "url": "https://github.com/hapijs/address/milestone/22",
+ "version": "5.1.0"
+ },
+ {
+ "date": "2022-05-02T05:42:21Z",
+ "id": 7793532,
+ "issues": [
+ {
+ "id": 1222504847,
+ "labels": ["breaking changes", "feature", "types"],
+ "number": 41,
+ "title": "Change API",
+ "url": "https://github.com/hapijs/address/issues/41"
+ },
+ {
+ "id": 1222504338,
+ "labels": ["breaking changes", "feature", "types"],
+ "number": 40,
+ "title": "Convert to TypeScript",
+ "url": "https://github.com/hapijs/address/issues/40"
+ },
+ {
+ "id": 1222245015,
+ "labels": ["breaking changes", "dependency"],
+ "number": 39,
+ "title": "Drop node 12 support",
+ "url": "https://github.com/hapijs/address/issues/39"
+ },
+ {
+ "id": 1202218015,
+ "labels": ["dependency"],
+ "number": 38,
+ "title": "Update tlds.js",
+ "url": "https://github.com/hapijs/address/pull/38"
+ }
+ ],
"number": 20,
- "title": "\"a@a.com/asd\" is invalid email",
- "url": "https://github.com/hapijs/address/issues/20"
- }
- ],
- "number": 10,
- "url": "https://github.com/hapijs/address/milestone/10",
- "version": "3.2.2"
- },
- {
- "date": "2019-11-17T05:50:55Z",
- "id": 4800325,
- "issues": [
- {
- "id": 523939966,
- "labels": ["bug"],
+ "url": "https://github.com/hapijs/address/milestone/20",
+ "version": "5.0.0"
+ },
+ {
+ "date": "2024-01-29T13:21:04Z",
+ "id": 10482555,
+ "issues": [
+ {
+ "id": 2105392579,
+ "labels": ["bug"],
+ "number": 47,
+ "title": "chore: update tlds",
+ "url": "https://github.com/hapijs/address/pull/47"
+ }
+ ],
+ "number": 24,
+ "url": "https://github.com/hapijs/address/milestone/24",
+ "version": "4.1.5"
+ },
+ {
+ "date": "2022-03-22T23:22:57Z",
+ "id": 7446122,
+ "issues": [
+ {
+ "id": 1173205659,
+ "labels": ["dependency"],
+ "number": 37,
+ "title": "Update the TLDS for email validation",
+ "url": "https://github.com/hapijs/address/pull/37"
+ }
+ ],
+ "number": 19,
+ "url": "https://github.com/hapijs/address/milestone/19",
+ "version": "4.1.4"
+ },
+ {
+ "date": "2021-12-01T08:38:39Z",
+ "id": 6735874,
+ "issues": [
+ {
+ "id": 957589243,
+ "labels": ["bug"],
+ "number": 36,
+ "title": "Invalid input error validating link in schema",
+ "url": "https://github.com/hapijs/address/issues/36"
+ },
+ {
+ "id": 654430948,
+ "labels": ["bug"],
+ "number": 31,
+ "title": "Incorrect validation",
+ "url": "https://github.com/hapijs/address/issues/31"
+ }
+ ],
"number": 18,
- "title": "Error on email",
- "url": "https://github.com/hapijs/address/issues/18"
- }
- ],
- "number": 9,
- "url": "https://github.com/hapijs/address/milestone/9",
- "version": "3.2.1"
- },
- {
- "date": "2019-10-30T23:35:01Z",
- "id": 4756274,
- "issues": [
- {
- "id": 515048003,
- "labels": ["feature"],
+ "url": "https://github.com/hapijs/address/milestone/18",
+ "version": "4.1.3"
+ },
+ {
+ "date": "2021-05-07T06:11:07Z",
+ "id": 6403302,
+ "issues": [
+ {
+ "id": 878502441,
+ "labels": ["bug"],
+ "number": 35,
+ "title": "Fails to invalidate URI delimiter chars on domain end",
+ "url": "https://github.com/hapijs/address/issues/35"
+ }
+ ],
+ "number": 17,
+ "url": "https://github.com/hapijs/address/milestone/17",
+ "version": "4.1.2"
+ },
+ {
+ "date": "2021-02-08T01:02:42Z",
+ "id": 5619718,
+ "issues": [
+ {
+ "id": 803109463,
+ "labels": ["bug"],
+ "number": 33,
+ "title": "Email validations rejects valid email addresses",
+ "url": "https://github.com/hapijs/address/issues/33"
+ }
+ ],
"number": 16,
- "title": "Add faster version of decodeURIComponent()",
- "url": "https://github.com/hapijs/address/issues/16"
- },
- {
- "id": 514435232,
- "labels": ["feature"],
+ "url": "https://github.com/hapijs/address/milestone/16",
+ "version": "4.1.1"
+ },
+ {
+ "date": "2020-07-06T01:17:17Z",
+ "id": 5200674,
+ "issues": [
+ {
+ "id": 651176115,
+ "labels": ["feature"],
+ "number": 30,
+ "title": "Support maxDomainSegments",
+ "url": "https://github.com/hapijs/address/issues/30"
+ }
+ ],
"number": 15,
- "title": "Relocate joi uri and ip validation regex",
- "url": "https://github.com/hapijs/address/issues/15"
- }
- ],
- "number": 8,
- "url": "https://github.com/hapijs/address/milestone/8",
- "version": "3.2.0"
- },
- {
- "date": "2019-10-16T04:38:58Z",
- "id": 4724458,
- "issues": [
- {
- "id": 506551200,
- "labels": ["feature"],
+ "url": "https://github.com/hapijs/address/milestone/15",
+ "version": "4.1.0"
+ },
+ {
+ "date": "2020-03-14T00:01:49Z",
+ "id": 4972515,
+ "issues": [
+ {
+ "id": 580941272,
+ "labels": ["bug"],
+ "number": 26,
+ "title": "Capture domain in relative uris",
+ "url": "https://github.com/hapijs/address/issues/26"
+ }
+ ],
"number": 14,
- "title": "Error codes in a separate file. Closes #13",
- "url": "https://github.com/hapijs/address/pull/14"
- },
- {
- "id": 505180439,
- "labels": ["feature"],
- "number": 13,
- "title": "Export errors codes to allow translation",
- "url": "https://github.com/hapijs/address/issues/13"
- }
- ],
- "number": 7,
- "url": "https://github.com/hapijs/address/milestone/7",
- "version": "3.1.0"
- },
- {
- "date": "2019-10-06T01:46:35Z",
- "id": 4724457,
- "issues": [
- {
- "id": 503024394,
- "labels": ["breaking changes", "types"],
+ "url": "https://github.com/hapijs/address/milestone/14",
+ "version": "4.0.1"
+ },
+ {
+ "date": "2020-01-04T08:47:36Z",
+ "id": 4972513,
+ "issues": [
+ {
+ "id": 545259529,
+ "labels": ["breaking changes", "dependency"],
+ "number": 24,
+ "title": "Only support node 12",
+ "url": "https://github.com/hapijs/address/issues/24"
+ }
+ ],
"number": 12,
- "title": "Add types",
- "url": "https://github.com/hapijs/address/issues/12"
- },
- {
- "id": 503024374,
- "labels": ["breaking changes"],
- "number": 11,
- "title": "Drop node 8 support",
- "url": "https://github.com/hapijs/address/issues/11"
- }
- ],
- "number": 6,
- "url": "https://github.com/hapijs/address/milestone/6",
- "version": "3.0.0"
- },
- {
- "date": "2020-01-04T08:41:53Z",
- "id": 4852229,
- "issues": [
- {
- "id": 523950299,
- "labels": ["bug"],
- "number": 21,
- "title": "Backport #20",
- "url": "https://github.com/hapijs/address/issues/21"
- }
- ],
- "number": 11,
- "url": "https://github.com/hapijs/address/milestone/11",
- "version": "2.1.4"
- },
- {
- "date": "2019-11-17T05:57:02Z",
- "id": 4678328,
- "issues": [
- {
- "id": 523941175,
- "labels": ["bug"],
- "number": 19,
- "title": "Backport #18",
- "url": "https://github.com/hapijs/address/issues/19"
- }
- ],
- "number": 5,
- "url": "https://github.com/hapijs/address/milestone/5",
- "version": "2.1.3"
- },
- {
- "date": "2019-09-20T20:04:52Z",
- "id": 4633488,
- "issues": [
- {
- "id": 496524175,
- "labels": ["dependency"],
+ "url": "https://github.com/hapijs/address/milestone/12",
+ "version": "4.0.0"
+ },
+ {
+ "date": "2020-01-04T08:42:34Z",
+ "id": 4852228,
+ "issues": [
+ {
+ "id": 523950264,
+ "labels": ["bug"],
+ "number": 20,
+ "title": "\"a@a.com/asd\" is invalid email",
+ "url": "https://github.com/hapijs/address/issues/20"
+ }
+ ],
+ "number": 10,
+ "url": "https://github.com/hapijs/address/milestone/10",
+ "version": "3.2.2"
+ },
+ {
+ "date": "2019-11-17T05:50:55Z",
+ "id": 4800325,
+ "issues": [
+ {
+ "id": 523939966,
+ "labels": ["bug"],
+ "number": 18,
+ "title": "Error on email",
+ "url": "https://github.com/hapijs/address/issues/18"
+ }
+ ],
"number": 9,
- "title": "Update tlds",
- "url": "https://github.com/hapijs/address/issues/9"
- },
- {
- "id": 496281024,
- "labels": ["bug"],
+ "url": "https://github.com/hapijs/address/milestone/9",
+ "version": "3.2.1"
+ },
+ {
+ "date": "2019-10-30T23:35:01Z",
+ "id": 4756274,
+ "issues": [
+ {
+ "id": 515048003,
+ "labels": ["feature"],
+ "number": 16,
+ "title": "Add faster version of decodeURIComponent()",
+ "url": "https://github.com/hapijs/address/issues/16"
+ },
+ {
+ "id": 514435232,
+ "labels": ["feature"],
+ "number": 15,
+ "title": "Relocate joi uri and ip validation regex",
+ "url": "https://github.com/hapijs/address/issues/15"
+ }
+ ],
"number": 8,
- "title": "Ensure Buffer presence before using it",
- "url": "https://github.com/hapijs/address/pull/8"
- },
- {
- "id": 489753207,
- "labels": ["dependency"],
+ "url": "https://github.com/hapijs/address/milestone/8",
+ "version": "3.2.0"
+ },
+ {
+ "date": "2019-10-16T04:38:58Z",
+ "id": 4724458,
+ "issues": [
+ {
+ "id": 506551200,
+ "labels": ["feature"],
+ "number": 14,
+ "title": "Error codes in a separate file. Closes #13",
+ "url": "https://github.com/hapijs/address/pull/14"
+ },
+ {
+ "id": 505180439,
+ "labels": ["feature"],
+ "number": 13,
+ "title": "Export errors codes to allow translation",
+ "url": "https://github.com/hapijs/address/issues/13"
+ }
+ ],
"number": 7,
- "title": "Re-implement #4, #6",
- "url": "https://github.com/hapijs/address/issues/7"
- }
- ],
- "number": 4,
- "url": "https://github.com/hapijs/address/milestone/4",
- "version": "2.1.2"
- },
- {
- "date": "2019-09-05T09:14:22Z",
- "id": 4623590,
- "issues": [
- {
- "id": 489628727,
- "labels": ["dependency"],
+ "url": "https://github.com/hapijs/address/milestone/7",
+ "version": "3.1.0"
+ },
+ {
+ "date": "2019-10-06T01:46:35Z",
+ "id": 4724457,
+ "issues": [
+ {
+ "id": 503024394,
+ "labels": ["breaking changes", "types"],
+ "number": 12,
+ "title": "Add types",
+ "url": "https://github.com/hapijs/address/issues/12"
+ },
+ {
+ "id": 503024374,
+ "labels": ["breaking changes"],
+ "number": 11,
+ "title": "Drop node 8 support",
+ "url": "https://github.com/hapijs/address/issues/11"
+ }
+ ],
"number": 6,
- "title": "Revert Url hack",
- "url": "https://github.com/hapijs/address/issues/6"
- }
- ],
- "number": 3,
- "url": "https://github.com/hapijs/address/milestone/3",
- "version": "2.1.1"
- },
- {
- "date": "2019-09-03T13:40:33Z",
- "id": 4167339,
- "issues": [
- {
- "id": 488612705,
- "labels": ["feature"],
+ "url": "https://github.com/hapijs/address/milestone/6",
+ "version": "3.0.0"
+ },
+ {
+ "date": "2020-01-04T08:41:53Z",
+ "id": 4852229,
+ "issues": [
+ {
+ "id": 523950299,
+ "labels": ["bug"],
+ "number": 21,
+ "title": "Backport #20",
+ "url": "https://github.com/hapijs/address/issues/21"
+ }
+ ],
+ "number": 11,
+ "url": "https://github.com/hapijs/address/milestone/11",
+ "version": "2.1.4"
+ },
+ {
+ "date": "2019-11-17T05:57:02Z",
+ "id": 4678328,
+ "issues": [
+ {
+ "id": 523941175,
+ "labels": ["bug"],
+ "number": 19,
+ "title": "Backport #18",
+ "url": "https://github.com/hapijs/address/issues/19"
+ }
+ ],
"number": 5,
- "title": "Make tlds optional",
- "url": "https://github.com/hapijs/address/issues/5"
- },
- {
- "id": 488146599,
- "labels": ["dependency"],
+ "url": "https://github.com/hapijs/address/milestone/5",
+ "version": "2.1.3"
+ },
+ {
+ "date": "2019-09-20T20:04:52Z",
+ "id": 4633488,
+ "issues": [
+ {
+ "id": 496524175,
+ "labels": ["dependency"],
+ "number": 9,
+ "title": "Update tlds",
+ "url": "https://github.com/hapijs/address/issues/9"
+ },
+ {
+ "id": 496281024,
+ "labels": ["bug"],
+ "number": 8,
+ "title": "Ensure Buffer presence before using it",
+ "url": "https://github.com/hapijs/address/pull/8"
+ },
+ {
+ "id": 489753207,
+ "labels": ["dependency"],
+ "number": 7,
+ "title": "Re-implement #4, #6",
+ "url": "https://github.com/hapijs/address/issues/7"
+ }
+ ],
"number": 4,
- "title": "Replace punycode dep with URL hack",
- "url": "https://github.com/hapijs/address/pull/4"
- },
- {
- "id": 465915090,
- "labels": ["feature"],
- "number": 1,
- "title": "Support option to allow longer email addresses",
- "url": "https://github.com/hapijs/address/issues/1"
- }
- ],
- "number": 2,
- "url": "https://github.com/hapijs/address/milestone/2",
- "version": "2.1.0"
- }
+ "url": "https://github.com/hapijs/address/milestone/4",
+ "version": "2.1.2"
+ },
+ {
+ "date": "2019-09-05T09:14:22Z",
+ "id": 4623590,
+ "issues": [
+ {
+ "id": 489628727,
+ "labels": ["dependency"],
+ "number": 6,
+ "title": "Revert Url hack",
+ "url": "https://github.com/hapijs/address/issues/6"
+ }
+ ],
+ "number": 3,
+ "url": "https://github.com/hapijs/address/milestone/3",
+ "version": "2.1.1"
+ },
+ {
+ "date": "2019-09-03T13:40:33Z",
+ "id": 4167339,
+ "issues": [
+ {
+ "id": 488612705,
+ "labels": ["feature"],
+ "number": 5,
+ "title": "Make tlds optional",
+ "url": "https://github.com/hapijs/address/issues/5"
+ },
+ {
+ "id": 488146599,
+ "labels": ["dependency"],
+ "number": 4,
+ "title": "Replace punycode dep with URL hack",
+ "url": "https://github.com/hapijs/address/pull/4"
+ },
+ {
+ "id": 465915090,
+ "labels": ["feature"],
+ "number": 1,
+ "title": "Support option to allow longer email addresses",
+ "url": "https://github.com/hapijs/address/issues/1"
+ }
+ ],
+ "number": 2,
+ "url": "https://github.com/hapijs/address/milestone/2",
+ "version": "2.1.0"
+ }
]
diff --git a/generated/modules/address/info.json b/generated/modules/address/info.json
index 28f9edf..78fb9a8 100644
--- a/generated/modules/address/info.json
+++ b/generated/modules/address/info.json
@@ -1,19 +1,19 @@
{
- "api": true,
- "forks": 27,
- "link": "https://github.com/hapijs/address",
- "name": "address",
- "package": "@hapi/address",
- "slogan": "Validate email address and domain.",
- "stars": 33,
- "updated": "2024-01-29T12:37:22Z",
- "versions": [
- {
- "branch": "v5.1.1",
- "license": "BSD",
- "name": "5.1.1",
- "node": ">= 14"
- }
- ],
- "versionsArray": ["5.1.1"]
+ "api": true,
+ "forks": 27,
+ "link": "https://github.com/hapijs/address",
+ "name": "address",
+ "package": "@hapi/address",
+ "slogan": "Validate email address and domain.",
+ "stars": 33,
+ "updated": "2024-01-29T12:37:22Z",
+ "versions": [
+ {
+ "branch": "v5.1.1",
+ "license": "BSD",
+ "name": "5.1.1",
+ "node": ">= 14"
+ }
+ ],
+ "versionsArray": ["5.1.1"]
}
diff --git a/generated/modules/formula/changelog.json b/generated/modules/formula/changelog.json
index cf80746..47564ca 100644
--- a/generated/modules/formula/changelog.json
+++ b/generated/modules/formula/changelog.json
@@ -1,112 +1,112 @@
[
- {
- "date": "2023-02-19T10:51:54Z",
- "id": 9063122,
- "issues": [
- {
- "id": 1590641372,
- "labels": [],
- "number": 11,
- "title": "chore: change package namespace",
- "url": "https://github.com/hapijs/formula/pull/11"
- }
- ],
- "number": 8,
- "url": "https://github.com/hapijs/formula/milestone/8",
- "version": "3.0.2"
- },
- {
- "date": "2023-02-19T10:50:16Z",
- "id": 4972530,
- "issues": [
- {
- "id": 1590642366,
- "labels": ["bug", "security"],
- "number": 12,
- "title": "fix redos on numbers",
- "url": "https://github.com/hapijs/formula/issues/12"
- }
- ],
- "number": 7,
- "url": "https://github.com/hapijs/formula/milestone/7",
- "version": "3.0.1"
- },
- {
- "date": "2020-01-04T08:54:02Z",
- "id": 4972529,
- "issues": [
- {
- "id": 545260282,
- "labels": ["breaking changes", "dependency"],
- "number": 10,
- "title": "Support only node 12",
- "url": "https://github.com/hapijs/formula/issues/10"
- }
- ],
- "number": 6,
- "url": "https://github.com/hapijs/formula/milestone/6",
- "version": "3.0.0"
- },
- {
- "date": "2019-10-07T04:46:26Z",
- "id": 4724607,
- "issues": [
- {
- "id": 503229738,
- "labels": ["breaking changes", "dependency"],
+ {
+ "date": "2023-02-19T10:51:54Z",
+ "id": 9063122,
+ "issues": [
+ {
+ "id": 1590641372,
+ "labels": [],
+ "number": 11,
+ "title": "chore: change package namespace",
+ "url": "https://github.com/hapijs/formula/pull/11"
+ }
+ ],
"number": 8,
- "title": "Drop node 8",
- "url": "https://github.com/hapijs/formula/issues/8"
- },
- {
- "id": 503046709,
- "labels": ["breaking changes"],
+ "url": "https://github.com/hapijs/formula/milestone/8",
+ "version": "3.0.2"
+ },
+ {
+ "date": "2023-02-19T10:50:16Z",
+ "id": 4972530,
+ "issues": [
+ {
+ "id": 1590642366,
+ "labels": ["bug", "security"],
+ "number": 12,
+ "title": "fix redos on numbers",
+ "url": "https://github.com/hapijs/formula/issues/12"
+ }
+ ],
"number": 7,
- "title": "Change default export",
- "url": "https://github.com/hapijs/formula/issues/7"
- },
- {
- "id": 503046658,
- "labels": ["types", "breaking changes"],
+ "url": "https://github.com/hapijs/formula/milestone/7",
+ "version": "3.0.1"
+ },
+ {
+ "date": "2020-01-04T08:54:02Z",
+ "id": 4972529,
+ "issues": [
+ {
+ "id": 545260282,
+ "labels": ["breaking changes", "dependency"],
+ "number": 10,
+ "title": "Support only node 12",
+ "url": "https://github.com/hapijs/formula/issues/10"
+ }
+ ],
"number": 6,
- "title": "Add types",
- "url": "https://github.com/hapijs/formula/issues/6"
- }
- ],
- "number": 4,
- "url": "https://github.com/hapijs/formula/milestone/4",
- "version": "2.0.0"
- },
- {
- "date": "2019-08-09T08:37:32Z",
- "id": 4437361,
- "issues": [
- {
- "id": 478867827,
- "labels": ["feature"],
+ "url": "https://github.com/hapijs/formula/milestone/6",
+ "version": "3.0.0"
+ },
+ {
+ "date": "2019-10-07T04:46:26Z",
+ "id": 4724607,
+ "issues": [
+ {
+ "id": 503229738,
+ "labels": ["breaking changes", "dependency"],
+ "number": 8,
+ "title": "Drop node 8",
+ "url": "https://github.com/hapijs/formula/issues/8"
+ },
+ {
+ "id": 503046709,
+ "labels": ["breaking changes"],
+ "number": 7,
+ "title": "Change default export",
+ "url": "https://github.com/hapijs/formula/issues/7"
+ },
+ {
+ "id": 503046658,
+ "labels": ["types", "breaking changes"],
+ "number": 6,
+ "title": "Add types",
+ "url": "https://github.com/hapijs/formula/issues/6"
+ }
+ ],
+ "number": 4,
+ "url": "https://github.com/hapijs/formula/milestone/4",
+ "version": "2.0.0"
+ },
+ {
+ "date": "2019-08-09T08:37:32Z",
+ "id": 4437361,
+ "issues": [
+ {
+ "id": 478867827,
+ "labels": ["feature"],
+ "number": 2,
+ "title": "Bind functions to context",
+ "url": "https://github.com/hapijs/formula/issues/2"
+ }
+ ],
"number": 2,
- "title": "Bind functions to context",
- "url": "https://github.com/hapijs/formula/issues/2"
- }
- ],
- "number": 2,
- "url": "https://github.com/hapijs/formula/milestone/2",
- "version": "1.2.0"
- },
- {
- "date": "2019-06-24T18:43:34Z",
- "id": 4437360,
- "issues": [
- {
- "id": 460038563,
- "labels": ["feature"],
+ "url": "https://github.com/hapijs/formula/milestone/2",
+ "version": "1.2.0"
+ },
+ {
+ "date": "2019-06-24T18:43:34Z",
+ "id": 4437360,
+ "issues": [
+ {
+ "id": 460038563,
+ "labels": ["feature"],
+ "number": 1,
+ "title": "Identify single part",
+ "url": "https://github.com/hapijs/formula/issues/1"
+ }
+ ],
"number": 1,
- "title": "Identify single part",
- "url": "https://github.com/hapijs/formula/issues/1"
- }
- ],
- "number": 1,
- "url": "https://github.com/hapijs/formula/milestone/1",
- "version": "1.1.0"
- }
+ "url": "https://github.com/hapijs/formula/milestone/1",
+ "version": "1.1.0"
+ }
]
diff --git a/generated/modules/formula/info.json b/generated/modules/formula/info.json
index 71ad005..9b64471 100644
--- a/generated/modules/formula/info.json
+++ b/generated/modules/formula/info.json
@@ -1,19 +1,19 @@
{
- "api": true,
- "forks": 20,
- "link": "https://github.com/hapijs/formula",
- "name": "formula",
- "package": "@hapi/formula",
- "slogan": "Math and string formula parser.",
- "stars": 17,
- "updated": "2024-02-02T16:21:44Z",
- "versions": [
- {
- "branch": "v3.0.2",
- "license": "BSD",
- "name": "3.0.2",
- "node": ">= 14"
- }
- ],
- "versionsArray": ["3.0.2"]
+ "api": true,
+ "forks": 20,
+ "link": "https://github.com/hapijs/formula",
+ "name": "formula",
+ "package": "@hapi/formula",
+ "slogan": "Math and string formula parser.",
+ "stars": 17,
+ "updated": "2024-02-02T16:21:44Z",
+ "versions": [
+ {
+ "branch": "v3.0.2",
+ "license": "BSD",
+ "name": "3.0.2",
+ "node": ">= 14"
+ }
+ ],
+ "versionsArray": ["3.0.2"]
}
diff --git a/generated/modules/joi-date/changelog.json b/generated/modules/joi-date/changelog.json
index 0f996e7..1a174e1 100644
--- a/generated/modules/joi-date/changelog.json
+++ b/generated/modules/joi-date/changelog.json
@@ -1,176 +1,176 @@
[
- {
- "date": "2024-04-22T09:08:12Z",
- "id": 6609017,
- "issues": [
- {
- "id": 2255988398,
- "labels": ["bug"],
- "number": 45,
- "title": "fix: wrong default export",
- "url": "https://github.com/hapijs/joi-date/pull/45"
- }
- ],
- "number": 10,
- "url": "https://github.com/hapijs/joi-date/milestone/10",
- "version": "2.1.1"
- },
- {
- "date": "2021-03-30T17:07:34Z",
- "id": 4724219,
- "issues": [
- {
- "id": 844462507,
- "labels": ["feature", "types"],
- "number": 38,
- "title": "Add typescript types",
- "url": "https://github.com/hapijs/joi-date/pull/38"
- },
- {
- "id": 537794284,
- "labels": ["types"],
- "number": 26,
- "title": "Typescript Support?",
- "url": "https://github.com/hapijs/joi-date/issues/26"
- }
- ],
- "number": 9,
- "url": "https://github.com/hapijs/joi-date/milestone/9",
- "version": "2.1.0"
- },
- {
- "date": "2019-10-05T17:39:20Z",
- "id": 4652451,
- "issues": [
- {
- "id": 499587630,
- "labels": ["bug"],
- "number": 25,
- "title": "Fails to enforce required format when value is a number string",
- "url": "https://github.com/hapijs/joi-date/issues/25"
- }
- ],
- "number": 8,
- "url": "https://github.com/hapijs/joi-date/milestone/8",
- "version": "2.0.1"
- },
- {
- "date": "2019-09-11T23:22:56Z",
- "id": 4247639,
- "issues": [
- {
- "id": 479153863,
- "labels": ["dependency", "breaking changes"],
- "number": 22,
- "title": "Support joi v16",
- "url": "https://github.com/hapijs/joi-date/issues/22"
- },
- {
- "id": 386290578,
- "labels": ["bug"],
- "number": 13,
- "title": "Issue with \".allow\" whitelists",
- "url": "https://github.com/hapijs/joi-date/issues/13"
- }
- ],
- "number": 7,
- "url": "https://github.com/hapijs/joi-date/milestone/7",
- "version": "2.0.0"
- },
- {
- "date": "2019-04-22T07:25:30Z",
- "id": 4247638,
- "issues": [
- {
- "id": 435622391,
- "labels": ["dependency"],
- "number": 17,
- "title": "Change module namespace",
- "url": "https://github.com/hapijs/joi-date/issues/17"
- }
- ],
- "number": 6,
- "url": "https://github.com/hapijs/joi-date/milestone/6",
- "version": "1.3.0"
- },
- {
- "date": "2019-04-22T06:55:33Z",
- "id": 3277572,
- "issues": [
- {
- "id": 312027071,
- "labels": ["feature"],
+ {
+ "date": "2024-04-22T09:08:12Z",
+ "id": 6609017,
+ "issues": [
+ {
+ "id": 2255988398,
+ "labels": ["bug"],
+ "number": 45,
+ "title": "fix: wrong default export",
+ "url": "https://github.com/hapijs/joi-date/pull/45"
+ }
+ ],
+ "number": 10,
+ "url": "https://github.com/hapijs/joi-date/milestone/10",
+ "version": "2.1.1"
+ },
+ {
+ "date": "2021-03-30T17:07:34Z",
+ "id": 4724219,
+ "issues": [
+ {
+ "id": 844462507,
+ "labels": ["feature", "types"],
+ "number": 38,
+ "title": "Add typescript types",
+ "url": "https://github.com/hapijs/joi-date/pull/38"
+ },
+ {
+ "id": 537794284,
+ "labels": ["types"],
+ "number": 26,
+ "title": "Typescript Support?",
+ "url": "https://github.com/hapijs/joi-date/issues/26"
+ }
+ ],
"number": 9,
- "title": "Add support for UTC parsing mode",
- "url": "https://github.com/hapijs/joi-date/pull/9"
- }
- ],
- "number": 5,
- "url": "https://github.com/hapijs/joi-date/milestone/5",
- "version": "1.2.0"
- },
- {
- "date": "2018-02-16T19:31:38Z",
- "id": 3123005,
- "issues": [
- {
- "id": 297846505,
- "labels": ["dependency"],
+ "url": "https://github.com/hapijs/joi-date/milestone/9",
+ "version": "2.1.0"
+ },
+ {
+ "date": "2019-10-05T17:39:20Z",
+ "id": 4652451,
+ "issues": [
+ {
+ "id": 499587630,
+ "labels": ["bug"],
+ "number": 25,
+ "title": "Fails to enforce required format when value is a number string",
+ "url": "https://github.com/hapijs/joi-date/issues/25"
+ }
+ ],
+ "number": 8,
+ "url": "https://github.com/hapijs/joi-date/milestone/8",
+ "version": "2.0.1"
+ },
+ {
+ "date": "2019-09-11T23:22:56Z",
+ "id": 4247639,
+ "issues": [
+ {
+ "id": 479153863,
+ "labels": ["dependency", "breaking changes"],
+ "number": 22,
+ "title": "Support joi v16",
+ "url": "https://github.com/hapijs/joi-date/issues/22"
+ },
+ {
+ "id": 386290578,
+ "labels": ["bug"],
+ "number": 13,
+ "title": "Issue with \".allow\" whitelists",
+ "url": "https://github.com/hapijs/joi-date/issues/13"
+ }
+ ],
"number": 7,
- "title": "fix(package): remove unused hoek dependency",
- "url": "https://github.com/hapijs/joi-date/pull/7"
- }
- ],
- "number": 4,
- "url": "https://github.com/hapijs/joi-date/milestone/4",
- "version": "1.1.1"
- },
- {
- "date": "2017-09-26T15:47:43Z",
- "id": 2795154,
- "issues": [
- {
- "id": 260659100,
- "labels": [],
+ "url": "https://github.com/hapijs/joi-date/milestone/7",
+ "version": "2.0.0"
+ },
+ {
+ "date": "2019-04-22T07:25:30Z",
+ "id": 4247638,
+ "issues": [
+ {
+ "id": 435622391,
+ "labels": ["dependency"],
+ "number": 17,
+ "title": "Change module namespace",
+ "url": "https://github.com/hapijs/joi-date/issues/17"
+ }
+ ],
+ "number": 6,
+ "url": "https://github.com/hapijs/joi-date/milestone/6",
+ "version": "1.3.0"
+ },
+ {
+ "date": "2019-04-22T06:55:33Z",
+ "id": 3277572,
+ "issues": [
+ {
+ "id": 312027071,
+ "labels": ["feature"],
+ "number": 9,
+ "title": "Add support for UTC parsing mode",
+ "url": "https://github.com/hapijs/joi-date/pull/9"
+ }
+ ],
"number": 5,
- "title": "feat(index): use provided joi instance",
- "url": "https://github.com/hapijs/joi-date/pull/5"
- }
- ],
- "number": 3,
- "url": "https://github.com/hapijs/joi-date/milestone/3",
- "version": "1.1.0"
- },
- {
- "date": "2017-09-26T15:47:44Z",
- "id": 2284541,
- "issues": [
- {
- "id": 203827772,
- "labels": ["bug"],
+ "url": "https://github.com/hapijs/joi-date/milestone/5",
+ "version": "1.2.0"
+ },
+ {
+ "date": "2018-02-16T19:31:38Z",
+ "id": 3123005,
+ "issues": [
+ {
+ "id": 297846505,
+ "labels": ["dependency"],
+ "number": 7,
+ "title": "fix(package): remove unused hoek dependency",
+ "url": "https://github.com/hapijs/joi-date/pull/7"
+ }
+ ],
+ "number": 4,
+ "url": "https://github.com/hapijs/joi-date/milestone/4",
+ "version": "1.1.1"
+ },
+ {
+ "date": "2017-09-26T15:47:43Z",
+ "id": 2795154,
+ "issues": [
+ {
+ "id": 260659100,
+ "labels": [],
+ "number": 5,
+ "title": "feat(index): use provided joi instance",
+ "url": "https://github.com/hapijs/joi-date/pull/5"
+ }
+ ],
"number": 3,
- "title": "Add Joi peerDependency",
- "url": "https://github.com/hapijs/joi-date/pull/3"
- }
- ],
- "number": 2,
- "url": "https://github.com/hapijs/joi-date/milestone/2",
- "version": "1.0.2"
- },
- {
- "date": "2016-11-22T16:19:54Z",
- "id": 2151876,
- "issues": [
- {
- "id": 191048766,
- "labels": ["bug"],
+ "url": "https://github.com/hapijs/joi-date/milestone/3",
+ "version": "1.1.0"
+ },
+ {
+ "date": "2017-09-26T15:47:44Z",
+ "id": 2284541,
+ "issues": [
+ {
+ "id": 203827772,
+ "labels": ["bug"],
+ "number": 3,
+ "title": "Add Joi peerDependency",
+ "url": "https://github.com/hapijs/joi-date/pull/3"
+ }
+ ],
"number": 2,
- "title": "Issue with optional date",
- "url": "https://github.com/hapijs/joi-date/issues/2"
- }
- ],
- "number": 1,
- "url": "https://github.com/hapijs/joi-date/milestone/1",
- "version": "1.0.1"
- }
+ "url": "https://github.com/hapijs/joi-date/milestone/2",
+ "version": "1.0.2"
+ },
+ {
+ "date": "2016-11-22T16:19:54Z",
+ "id": 2151876,
+ "issues": [
+ {
+ "id": 191048766,
+ "labels": ["bug"],
+ "number": 2,
+ "title": "Issue with optional date",
+ "url": "https://github.com/hapijs/joi-date/issues/2"
+ }
+ ],
+ "number": 1,
+ "url": "https://github.com/hapijs/joi-date/milestone/1",
+ "version": "1.0.1"
+ }
]
diff --git a/generated/modules/joi-date/info.json b/generated/modules/joi-date/info.json
index 0667569..bb23a64 100644
--- a/generated/modules/joi-date/info.json
+++ b/generated/modules/joi-date/info.json
@@ -1,19 +1,19 @@
{
- "api": true,
- "forks": 23,
- "link": "https://github.com/hapijs/joi-date",
- "name": "joi-date",
- "package": "@joi/date",
- "slogan": "Extensions for advance date rules.",
- "stars": 81,
- "updated": "2024-04-22T09:05:34Z",
- "versions": [
- {
- "branch": "v2.1.1",
- "license": "BSD",
- "name": "2.1.1",
- "node": ">= 14"
- }
- ],
- "versionsArray": ["2.1.1"]
+ "api": true,
+ "forks": 23,
+ "link": "https://github.com/hapijs/joi-date",
+ "name": "joi-date",
+ "package": "@joi/date",
+ "slogan": "Extensions for advance date rules.",
+ "stars": 81,
+ "updated": "2024-04-22T09:05:34Z",
+ "versions": [
+ {
+ "branch": "v2.1.1",
+ "license": "BSD",
+ "name": "2.1.1",
+ "node": ">= 14"
+ }
+ ],
+ "versionsArray": ["2.1.1"]
}
diff --git a/generated/modules/joi/changelog.json b/generated/modules/joi/changelog.json
index 1f34420..dc07b1f 100644
--- a/generated/modules/joi/changelog.json
+++ b/generated/modules/joi/changelog.json
@@ -1,8673 +1,8689 @@
[
- {
- "date": "2026-05-04T16:09:20Z",
- "id": 15790448,
- "issues": [
- {
- "id": 4377943724,
- "labels": ["bug"],
- "number": 3113,
- "title": "fix: protect link recursion from max call stack",
- "url": "https://github.com/hapijs/joi/pull/3113"
- }
- ],
- "number": 214,
- "url": "https://github.com/hapijs/joi/milestone/214",
- "version": "18.2.1"
- },
- {
- "date": "2026-05-04T15:16:15Z",
- "id": 15789816,
- "issues": [
- {
- "id": 4377623767,
- "labels": ["feature"],
- "number": 3111,
- "title": "feat: add maxRecursion limit to links",
- "url": "https://github.com/hapijs/joi/pull/3111"
- },
- {
- "id": 1150539161,
- "labels": ["support"],
- "number": 2747,
- "title": "Limit depth of self-referencing schema",
- "url": "https://github.com/hapijs/joi/issues/2747"
- }
- ],
- "number": 213,
- "url": "https://github.com/hapijs/joi/milestone/213",
- "version": "18.2.0"
- },
- {
- "date": "2026-03-30T18:05:09Z",
- "id": 15356910,
- "issues": [
- {
- "id": 4166157537,
- "labels": ["bug"],
- "number": 3107,
- "title": "fix: improve JSON Schema conversion for number.port() and number.sign()",
- "url": "https://github.com/hapijs/joi/pull/3107"
- }
- ],
- "number": 212,
- "url": "https://github.com/hapijs/joi/milestone/212",
- "version": "18.1.2"
- },
- {
- "date": "2026-03-23T17:52:59Z",
- "id": 15258251,
- "issues": [
- {
- "id": 4114694252,
- "labels": ["bug"],
- "number": 3103,
- "title": "fix: allow NaN in schema describe() output validation",
- "url": "https://github.com/hapijs/joi/pull/3103"
- },
- {
- "id": 3936661366,
- "labels": ["bug"],
- "number": 3099,
- "title": "Fix braces escaping when template doesn't contains any variable",
- "url": "https://github.com/hapijs/joi/pull/3099"
- },
- {
- "id": 3927008897,
- "labels": ["bug"],
- "number": 3098,
- "title": "Support libraryOptions in standard validator validate()",
- "url": "https://github.com/hapijs/joi/issues/3098"
- },
- {
- "id": 3926990031,
- "labels": ["bug"],
- "number": 3097,
- "title": "feat: enhance validation to support options in standard function",
- "url": "https://github.com/hapijs/joi/pull/3097"
- },
- {
- "id": 3749176772,
- "labels": ["bug"],
- "number": 3094,
- "title": "any.describe() throws an error if the schema contains .allow(NaN)",
- "url": "https://github.com/hapijs/joi/issues/3094"
- }
- ],
- "number": 211,
- "url": "https://github.com/hapijs/joi/milestone/211",
- "version": "18.1.1"
- },
- {
- "date": "2026-03-23T17:05:08Z",
- "id": 15216237,
- "issues": [
- {
- "id": 4098194752,
- "labels": ["feature"],
- "number": 3102,
- "title": "feat: add Standard JSON Schema",
- "url": "https://github.com/hapijs/joi/pull/3102"
- },
- {
- "id": 3922339917,
- "labels": ["feature"],
- "number": 3096,
- "title": "Consider implementing Standard JSON Schema",
- "url": "https://github.com/hapijs/joi/issues/3096"
- }
- ],
- "number": 210,
- "url": "https://github.com/hapijs/joi/milestone/210",
- "version": "18.1.0"
- },
- {
- "date": "2025-11-19T15:50:15Z",
- "id": 14176130,
- "issues": [
- {
- "id": 3563309382,
- "labels": ["bug"],
- "number": 3092,
- "title": "fix: allow coercion of string booleans with trailing whitespace",
- "url": "https://github.com/hapijs/joi/pull/3092"
- },
- {
- "id": 3546328972,
- "labels": ["bug"],
- "number": 3091,
- "title": "Joi.boolean() does not handle strings with trailing spaces",
- "url": "https://github.com/hapijs/joi/issues/3091"
- }
- ],
- "number": 209,
- "url": "https://github.com/hapijs/joi/milestone/209",
- "version": "18.0.2"
- },
- {
- "date": "2025-08-20T08:21:01Z",
- "id": 13527492,
- "issues": [
- {
- "id": 3306222585,
- "labels": ["types"],
- "number": 3087,
- "title": "fix: proper types for more complex cases of array",
- "url": "https://github.com/hapijs/joi/pull/3087"
- },
- {
- "id": 3305853768,
- "labels": ["bug", "types"],
- "number": 3086,
- "title": ".array().items() dynamic type item type schema causes issues in typescript",
- "url": "https://github.com/hapijs/joi/issues/3086"
- }
- ],
- "number": 208,
- "url": "https://github.com/hapijs/joi/milestone/208",
- "version": "18.0.1"
- },
- {
- "date": "2025-08-03T15:02:01Z",
- "id": 9147309,
- "issues": [
- {
- "id": 3278056010,
- "labels": ["feature"],
- "number": 3084,
- "title": "feat: add isAsync() helper",
- "url": "https://github.com/hapijs/joi/pull/3084"
- },
- {
- "id": 3150627812,
- "labels": ["feature"],
- "number": 3082,
- "title": "Added wrapper option to uuid function",
- "url": "https://github.com/hapijs/joi/pull/3082"
- },
- {
- "id": 3101562683,
- "labels": ["feature"],
- "number": 3080,
- "title": "feat: implement standard schema spec",
- "url": "https://github.com/hapijs/joi/pull/3080"
- },
- {
- "id": 3092026275,
- "labels": ["feature"],
- "number": 3078,
- "title": "Implement Standard Schema",
- "url": "https://github.com/hapijs/joi/issues/3078"
- },
- {
- "id": 1953253079,
- "labels": ["support"],
- "number": 2993,
- "title": "What version of node does this library support?",
- "url": "https://github.com/hapijs/joi/issues/2993"
- },
- {
- "id": 1865188160,
- "labels": ["types"],
- "number": 2982,
- "title": "feat: Improve array().items type",
- "url": "https://github.com/hapijs/joi/pull/2982"
- },
- {
- "id": 1865047279,
- "labels": ["types"],
- "number": 2981,
- "title": "feat: Improve alternatives type",
- "url": "https://github.com/hapijs/joi/pull/2981"
- },
- {
- "id": 1620062252,
- "labels": ["feature", "breaking changes", "release notes"],
- "number": 2926,
- "title": "18.0.0 Release Notes",
- "url": "https://github.com/hapijs/joi/issues/2926"
- },
- {
- "id": 1620047715,
- "labels": ["feature", "breaking changes", "dependency"],
- "number": 2925,
- "title": "chore: upgrade modules",
- "url": "https://github.com/hapijs/joi/pull/2925"
- }
- ],
- "number": 190,
- "url": "https://github.com/hapijs/joi/milestone/190",
- "version": "18.0.0"
- },
- {
- "date": "2024-06-19T15:17:24Z",
- "id": 11206916,
- "issues": [
- {
- "id": 2362616850,
- "labels": ["bug"],
- "number": 3043,
- "title": "fix: correct function type in alternatives error",
- "url": "https://github.com/hapijs/joi/pull/3043"
- }
- ],
- "number": 207,
- "url": "https://github.com/hapijs/joi/milestone/207",
- "version": "17.13.3"
- },
- {
- "date": "2024-06-19T12:37:04Z",
- "id": 11205378,
- "issues": [
- {
- "id": 2295899329,
- "labels": ["bug"],
- "number": 3037,
- "title": "fix: `stripUnknown` should honor local explicit `.unknown(false)`",
- "url": "https://github.com/hapijs/joi/pull/3037"
- }
- ],
- "number": 206,
- "url": "https://github.com/hapijs/joi/milestone/206",
- "version": "17.13.2"
- },
- {
- "date": "2024-06-19T09:15:12Z",
- "id": 11000255,
- "issues": [
- {
- "id": 2274746403,
- "labels": ["bug"],
- "number": 3034,
- "title": "fix: label false should also hide explicit labels",
- "url": "https://github.com/hapijs/joi/pull/3034"
- },
- {
- "id": 2273576913,
- "labels": ["bug"],
- "number": 3033,
- "title": "Setting `errors.label` to `false` does not remove labels from error messages for keys with labels",
- "url": "https://github.com/hapijs/joi/issues/3033"
- }
- ],
- "number": 205,
- "url": "https://github.com/hapijs/joi/milestone/205",
- "version": "17.13.1"
- },
- {
- "date": "2024-04-23T08:35:37Z",
- "id": 10769457,
- "issues": [
- {
- "id": 2258261381,
- "labels": ["feature"],
- "number": 3032,
- "title": "feat: support encoding uri (follow-up to #3027)",
- "url": "https://github.com/hapijs/joi/pull/3032"
- },
- {
- "id": 2216423112,
- "labels": ["feature"],
- "number": 3027,
- "title": "feat: Support encoding uri",
- "url": "https://github.com/hapijs/joi/pull/3027"
- },
- {
- "id": 1489081742,
- "labels": ["feature"],
- "number": 2889,
- "title": "string().uri() not working with accented characters",
- "url": "https://github.com/hapijs/joi/issues/2889"
- }
- ],
- "number": 204,
- "url": "https://github.com/hapijs/joi/milestone/204",
- "version": "17.13.0"
- },
- {
- "date": "2024-04-03T21:37:44Z",
- "id": 10769395,
- "issues": [
- {
- "id": 2215661765,
- "labels": ["bug"],
- "number": 3026,
- "title": "fix: handle bigint in unique rule",
- "url": "https://github.com/hapijs/joi/pull/3026"
- }
- ],
- "number": 203,
- "url": "https://github.com/hapijs/joi/milestone/203",
- "version": "17.12.3"
- },
- {
- "date": "2024-02-21T18:44:59Z",
- "id": 10588351,
- "issues": [
- {
- "id": 2139645423,
- "labels": ["types"],
- "number": 3018,
- "title": "Fix issue 2730 - Wrong State['path'] type",
- "url": "https://github.com/hapijs/joi/pull/3018"
- },
- {
- "id": 1111849600,
- "labels": ["types"],
- "number": 2730,
- "title": "Wrong `State['path']` type",
- "url": "https://github.com/hapijs/joi/issues/2730"
- }
- ],
- "number": 202,
- "url": "https://github.com/hapijs/joi/milestone/202",
- "version": "17.12.2"
- },
- {
- "date": "2024-01-29T13:44:48Z",
- "id": 10482661,
- "issues": [
- {
- "id": 2105483334,
- "labels": ["bug"],
- "number": 3016,
- "title": "fix: domain default tld validation",
- "url": "https://github.com/hapijs/joi/pull/3016"
- },
- {
- "id": 2097724714,
- "labels": ["bug"],
- "number": 3015,
- "title": "fix: domain default tld validation",
- "url": "https://github.com/hapijs/joi/pull/3015"
- },
- {
- "id": 2049526270,
- "labels": ["bug"],
- "number": 3007,
- "title": "Domain validation not checking IANA registry by default",
- "url": "https://github.com/hapijs/joi/issues/3007"
- }
- ],
- "number": 201,
- "url": "https://github.com/hapijs/joi/milestone/201",
- "version": "17.12.1"
- },
- {
- "date": "2024-01-18T00:04:23Z",
- "id": 10431827,
- "issues": [
- {
- "id": 2087195431,
- "labels": ["feature"],
- "number": 3014,
- "title": "feat: hex prefix",
- "url": "https://github.com/hapijs/joi/pull/3014"
- },
- {
- "id": 2073453048,
- "labels": ["feature"],
- "number": 3011,
- "title": "Allow 0x prefix for hex strings",
- "url": "https://github.com/hapijs/joi/pull/3011"
- },
- {
- "id": 641339086,
- "labels": ["bug", "feature"],
- "number": 2386,
- "title": "Allow 0x prefix for hex strings",
- "url": "https://github.com/hapijs/joi/issues/2386"
- }
- ],
- "number": 200,
- "url": "https://github.com/hapijs/joi/milestone/200",
- "version": "17.12.0"
- },
- {
- "date": "2024-01-15T13:06:38Z",
- "id": 10419385,
- "issues": [
- {
- "id": 2081693958,
- "labels": ["bug"],
- "number": 3013,
- "title": "fix: precision issue on number().multiple()",
- "url": "https://github.com/hapijs/joi/pull/3013"
- },
- {
- "id": 2068151437,
- "labels": ["bug", "types"],
- "number": 3009,
- "title": "fix: LanguageMessages type now supports languages in TypeScript",
- "url": "https://github.com/hapijs/joi/pull/3009"
- },
- {
- "id": 1990728854,
- "labels": ["bug"],
- "number": 3001,
- "title": "fix: do not override existing labels of underlying schemas in alternatives",
- "url": "https://github.com/hapijs/joi/pull/3001"
- },
- {
- "id": 1787687666,
- "labels": ["bug", "support"],
- "number": 2962,
- "title": "Multiple doesn't work correct",
- "url": "https://github.com/hapijs/joi/issues/2962"
- },
- {
- "id": 1440500562,
- "labels": ["documentation", "types"],
- "number": 2875,
- "title": "Fix for #2874",
- "url": "https://github.com/hapijs/joi/pull/2875"
- },
- {
- "id": 1440478135,
- "labels": ["support"],
- "number": 2874,
- "title": "Missing helper.error() method parameter type definition",
- "url": "https://github.com/hapijs/joi/issues/2874"
- },
- {
- "id": 1097031270,
- "labels": ["types"],
- "number": 2720,
- "title": "Type declaration for `messages` option of any.validate() inconsistent with the documentation and actual code",
- "url": "https://github.com/hapijs/joi/issues/2720"
- }
- ],
- "number": 199,
- "url": "https://github.com/hapijs/joi/milestone/199",
- "version": "17.11.1"
- },
- {
- "date": "2023-10-04T14:25:52Z",
- "id": 10001154,
- "issues": [
- {
- "id": 1926334194,
- "labels": ["feature"],
- "number": 2988,
- "title": "feat: allow custom expression functions",
- "url": "https://github.com/hapijs/joi/pull/2988"
- }
- ],
- "number": 198,
- "url": "https://github.com/hapijs/joi/milestone/198",
- "version": "17.11.0"
- },
- {
- "date": "2023-09-17T15:57:12Z",
- "id": 9931143,
- "issues": [
- {
- "id": 1899827281,
- "labels": ["bug"],
- "number": 2986,
- "title": "fix: missing template reference",
- "url": "https://github.com/hapijs/joi/pull/2986"
- },
- {
- "id": 1895279030,
- "labels": ["bug"],
- "number": 2985,
- "title": "Unit test showing example of formula parsing bug",
- "url": "https://github.com/hapijs/joi/pull/2985"
- },
- {
- "id": 1850594151,
- "labels": ["bug", "support"],
- "number": 2974,
- "title": "Unable to access object property with a space in its key via expression templates",
- "url": "https://github.com/hapijs/joi/issues/2974"
- }
- ],
- "number": 197,
- "url": "https://github.com/hapijs/joi/milestone/197",
- "version": "17.10.2"
- },
- {
- "date": "2023-08-31T15:49:29Z",
- "id": 9865466,
- "issues": [
- {
- "id": 1875799190,
- "labels": ["types"],
- "number": 2983,
- "title": "fix: allow any.error() return type to be ErrorReport[]",
- "url": "https://github.com/hapijs/joi/pull/2983"
- }
- ],
- "number": 196,
- "url": "https://github.com/hapijs/joi/milestone/196",
- "version": "17.10.1"
- },
- {
- "date": "2023-08-27T17:04:32Z",
- "id": 9846520,
- "issues": [
- {
- "id": 1853085465,
- "labels": ["types"],
- "number": 2975,
- "title": "property metas in Description",
- "url": "https://github.com/hapijs/joi/pull/2975"
- },
- {
- "id": 1790067587,
- "labels": ["types"],
- "number": 2964,
- "title": "#2963 make return value of validate match type definitions",
- "url": "https://github.com/hapijs/joi/pull/2964"
- },
- {
- "id": 1781265663,
- "labels": ["types"],
- "number": 2961,
- "title": "Associate Buffer with BinarySchema",
- "url": "https://github.com/hapijs/joi/pull/2961"
- },
- {
- "id": 1777924204,
- "labels": ["feature"],
- "number": 2960,
- "title": "feat: support bindary buffer that has been JSON.parse(JSON.strinified())",
- "url": "https://github.com/hapijs/joi/pull/2960"
- },
- {
- "id": 1761576894,
- "labels": ["feature"],
- "number": 2957,
- "title": "feat: support uuidv6, uuidv7 and uuidv8 guid types",
- "url": "https://github.com/hapijs/joi/pull/2957"
- },
- {
- "id": 1741458259,
- "labels": ["feature"],
- "number": 2954,
- "title": "Coerce toJSON'ed Buffer to real Buffer",
- "url": "https://github.com/hapijs/joi/issues/2954"
- }
- ],
- "number": 195,
- "url": "https://github.com/hapijs/joi/milestone/195",
- "version": "17.10.0"
- },
- {
- "date": "2023-04-24T20:47:29Z",
- "id": 9321545,
- "issues": [
- {
- "id": 1681703485,
- "labels": ["bug"],
- "number": 2945,
- "title": "fix: commit states to avoid memory leak",
- "url": "https://github.com/hapijs/joi/pull/2945"
- }
- ],
- "number": 194,
- "url": "https://github.com/hapijs/joi/milestone/194",
- "version": "17.9.2"
- },
- {
- "date": "2023-03-21T08:42:49Z",
- "id": 9183895,
- "issues": [
- {
- "id": 1632983659,
- "labels": ["bug"],
- "number": 2932,
- "title": "fix: do not trigger warnings and externals on arrays and alternatives mismatches",
- "url": "https://github.com/hapijs/joi/pull/2932"
- }
- ],
- "number": 193,
- "url": "https://github.com/hapijs/joi/milestone/193",
- "version": "17.9.1"
- },
- {
- "date": "2023-03-20T08:25:14Z",
- "id": 9175644,
- "issues": [
- {
- "id": 1630304936,
- "labels": ["feature"],
- "number": 2931,
- "title": "feat: improve external helpers",
- "url": "https://github.com/hapijs/joi/pull/2931"
- }
- ],
- "number": 192,
- "url": "https://github.com/hapijs/joi/milestone/192",
- "version": "17.9.0"
- },
- {
- "date": "2023-03-20T08:25:12Z",
- "id": 9156029,
- "issues": [
- {
- "id": 1622804267,
- "labels": ["bug", "types"],
- "number": 2928,
- "title": "fix: validation warning types",
- "url": "https://github.com/hapijs/joi/pull/2928"
- },
- {
- "id": 1620230465,
- "labels": ["support", "types"],
- "number": 2927,
- "title": "Type definition incorrect for \"warning\" return type from validateAsync",
- "url": "https://github.com/hapijs/joi/issues/2927"
- }
- ],
- "number": 191,
- "url": "https://github.com/hapijs/joi/milestone/191",
- "version": "17.8.4"
- },
- {
- "date": "2023-03-20T08:25:09Z",
- "id": 9070660,
- "issues": [
- {
- "id": 1593084729,
- "labels": [],
- "number": 2919,
- "title": "chore: revert 17.8.x line",
- "url": "https://github.com/hapijs/joi/pull/2919"
- },
- {
- "id": 1593002882,
- "labels": ["support"],
- "number": 2917,
- "title": "Cannot find module '@hapi/hoek/assert' from 'index.js'",
- "url": "https://github.com/hapijs/joi/issues/2917"
- },
- {
- "id": 1592248117,
- "labels": ["support"],
- "number": 2914,
- "title": "Support for older Node versions maybe lost in v17.8",
- "url": "https://github.com/hapijs/joi/issues/2914"
- },
- {
- "id": 1591944994,
- "labels": ["support"],
- "number": 2913,
- "title": "node_modules/@hapi/hoek/lib/deepEqual.js:274 ",
- "url": "https://github.com/hapijs/joi/issues/2913"
- }
- ],
- "number": 189,
- "url": "https://github.com/hapijs/joi/milestone/189",
- "version": "17.8.3"
- },
- {
- "date": "2023-03-20T08:25:06Z",
- "id": 9070155,
- "issues": [
- {
- "id": 1592981259,
- "labels": ["bug"],
- "number": 2916,
- "title": "fix: properly transform domain",
- "url": "https://github.com/hapijs/joi/pull/2916"
- },
- {
- "id": 1592497687,
- "labels": ["bug", "support"],
- "number": 2915,
- "title": "Email validation error in v17.8.1",
- "url": "https://github.com/hapijs/joi/issues/2915"
- }
- ],
- "number": 188,
- "url": "https://github.com/hapijs/joi/milestone/188",
- "version": "17.8.2"
- },
- {
- "date": "2023-02-19T12:33:29Z",
- "id": 9063278,
- "issues": [
- {
- "id": 1590670833,
- "labels": ["bug"],
- "number": 2910,
- "title": "fix: transpile optional chaining",
- "url": "https://github.com/hapijs/joi/pull/2910"
- }
- ],
- "number": 187,
- "url": "https://github.com/hapijs/joi/milestone/187",
- "version": "17.8.1"
- },
- {
- "date": "2023-02-19T11:51:58Z",
- "id": 9063202,
- "issues": [
- {
- "id": 1590656187,
- "labels": ["feature"],
- "number": 2909,
- "title": "chore: use latest address module",
- "url": "https://github.com/hapijs/joi/pull/2909"
- },
- {
- "id": 936359343,
- "labels": ["feature"],
- "number": 2630,
- "title": "Joi.string().domain() treats '_http._tcp.archive.ubuntu.com' as invalid domain name, even though it works",
- "url": "https://github.com/hapijs/joi/issues/2630"
- }
- ],
- "number": 186,
- "url": "https://github.com/hapijs/joi/milestone/186",
- "version": "17.8.0"
- },
- {
- "date": "2023-02-19T11:51:56Z",
- "id": 9004988,
- "issues": [
- {
- "id": 1578167134,
- "labels": [],
- "number": 2905,
- "title": "Upgrade `@sideway/formula` to `3.0.1` for `CVE-2023-25166`",
- "url": "https://github.com/hapijs/joi/pull/2905"
- },
- {
- "id": 1504691590,
- "labels": [],
- "number": 2892,
- "title": "Allow null values in BooleanSchema methods",
- "url": "https://github.com/hapijs/joi/pull/2892"
- }
- ],
- "number": 185,
- "url": "https://github.com/hapijs/joi/milestone/185",
- "version": "17.7.1"
- },
- {
- "date": "2022-11-10T10:33:24Z",
- "id": 8569458,
- "issues": [
- {
- "id": 1419419908,
- "labels": ["bug"],
- "number": 2867,
- "title": "fix: better unsafe check of exponential numbers",
- "url": "https://github.com/hapijs/joi/pull/2867"
- },
- {
- "id": 1193366281,
- "labels": ["feature"],
- "number": 2762,
- "title": "Add isPresent option to object dependencies",
- "url": "https://github.com/hapijs/joi/pull/2762"
- },
- {
- "id": 992008366,
- "labels": ["bug"],
- "number": 2672,
- "title": "Some exponential notation strings are validated as unsafe numbers",
- "url": "https://github.com/hapijs/joi/issues/2672"
- },
- {
- "id": 790848333,
- "labels": ["bug"],
- "number": 2542,
- "title": "Number validation fails on some strings with E-notation",
- "url": "https://github.com/hapijs/joi/issues/2542"
- }
- ],
- "number": 184,
- "url": "https://github.com/hapijs/joi/milestone/184",
- "version": "17.7.0"
- },
- {
- "date": "2022-10-22T10:08:17Z",
- "id": 8538155,
- "issues": [
- {
- "id": 1401515258,
- "labels": ["bug"],
- "number": 2859,
- "title": "Fix/throwing errors if required argument is omitted",
- "url": "https://github.com/hapijs/joi/pull/2859"
- },
- {
- "id": 1111295993,
- "labels": ["bug"],
- "number": 2729,
- "title": "Some validation methods don't throw an error when their required argument is omitted",
- "url": "https://github.com/hapijs/joi/issues/2729"
- }
- ],
- "number": 183,
- "url": "https://github.com/hapijs/joi/milestone/183",
- "version": "17.6.4"
- },
- {
- "date": "2022-10-11T10:04:10Z",
- "id": 8527121,
- "issues": [
- {
- "id": 1404259103,
- "labels": ["types"],
- "number": 2860,
- "title": "fix: allow all schema types to be defined and inferred",
- "url": "https://github.com/hapijs/joi/pull/2860"
- },
- {
- "id": 1399539454,
- "labels": ["support", "types"],
- "number": 2857,
- "title": "Typing issues with `attempt()`",
- "url": "https://github.com/hapijs/joi/issues/2857"
- },
- {
- "id": 1168824082,
- "labels": ["types"],
- "number": 2753,
- "title": "Typescript typing on `Joi.string().validate(...)`",
- "url": "https://github.com/hapijs/joi/issues/2753"
- }
- ],
- "number": 182,
- "url": "https://github.com/hapijs/joi/milestone/182",
- "version": "17.6.3"
- },
- {
- "date": "2022-09-29T16:09:13Z",
- "id": 8474927,
- "issues": [
- {
- "id": 1390907633,
- "labels": ["bug", "types"],
- "number": 2851,
- "title": "Try improving handling of unions",
- "url": "https://github.com/hapijs/joi/pull/2851"
- },
- {
- "id": 1389694070,
- "labels": ["bug", "types"],
- "number": 2850,
- "title": "fix: do not confuse booleans for alernatives in strict mode",
- "url": "https://github.com/hapijs/joi/pull/2850"
- },
- {
- "id": 1386182303,
- "labels": ["bug", "support", "types"],
- "number": 2848,
- "title": "Strict object schema with a boolean property expects alternative, not boolean",
- "url": "https://github.com/hapijs/joi/issues/2848"
- }
- ],
- "number": 181,
- "url": "https://github.com/hapijs/joi/milestone/181",
- "version": "17.6.2"
- },
- {
- "date": "2022-09-22T12:01:44Z",
- "id": 7613961,
- "issues": [
- {
- "id": 1382305421,
- "labels": ["types"],
- "number": 2844,
- "title": "types: support strict alternatives",
- "url": "https://github.com/hapijs/joi/pull/2844"
- },
- {
- "id": 1381290506,
- "labels": ["documentation"],
- "number": 2843,
- "title": "chore: update license",
- "url": "https://github.com/hapijs/joi/pull/2843"
- },
- {
- "id": 1379928615,
- "labels": ["documentation"],
- "number": 2842,
- "title": "Fix spelling",
- "url": "https://github.com/hapijs/joi/pull/2842"
- },
- {
- "id": 1379928379,
- "labels": ["types"],
- "number": 2841,
- "title": "Allow sub-objects for TypeScript strict object schema",
- "url": "https://github.com/hapijs/joi/pull/2841"
- },
- {
- "id": 1376827292,
- "labels": ["types"],
- "number": 2838,
- "title": "feat: change validateAsync return type to match options",
- "url": "https://github.com/hapijs/joi/pull/2838"
- },
- {
- "id": 1369594276,
- "labels": ["bug", "types"],
- "number": 2836,
- "title": "fix(d.ts): allow nested object schema for strictly typed object",
- "url": "https://github.com/hapijs/joi/pull/2836"
- },
- {
- "id": 1358610733,
- "labels": ["types"],
- "number": 2829,
- "title": "fix(d.ts)!: type details param of ValidationError constructor",
- "url": "https://github.com/hapijs/joi/pull/2829"
- },
- {
- "id": 1342785924,
- "labels": ["types"],
- "number": 2819,
- "title": "Add artifact to typings.",
- "url": "https://github.com/hapijs/joi/pull/2819"
- },
- {
- "id": 1342775051,
- "labels": ["types"],
- "number": 2818,
- "title": "Typescript support for .artifact()",
- "url": "https://github.com/hapijs/joi/issues/2818"
- },
- {
- "id": 1327774733,
- "labels": [],
- "number": 2813,
- "title": "Fix Joi issue #2746",
- "url": "https://github.com/hapijs/joi/pull/2813"
- },
- {
- "id": 1320932027,
- "labels": ["types"],
- "number": 2808,
- "title": "feat(d.ts): Add type information for `maxDomainSegments` to `EmailOptions` and `DomainOptions` interfaces",
- "url": "https://github.com/hapijs/joi/pull/2808"
- },
- {
- "id": 1284095708,
- "labels": ["types"],
- "number": 2797,
- "title": "feat(d.ts): improve attempt return type",
- "url": "https://github.com/hapijs/joi/pull/2797"
- },
- {
- "id": 1256690639,
- "labels": ["types"],
- "number": 2788,
- "title": "Include local into `ErrorReport` type",
- "url": "https://github.com/hapijs/joi/pull/2788"
- },
- {
- "id": 1243930480,
- "labels": ["bug", "types"],
- "number": 2785,
- "title": "fix(typings): incompatible type issue for nested strict object schemas",
- "url": "https://github.com/hapijs/joi/pull/2785"
- },
- {
- "id": 1202296754,
- "labels": ["bug", "types"],
- "number": 2764,
- "title": "Incompatible type expected for object schemas nested in strict object schemas",
- "url": "https://github.com/hapijs/joi/issues/2764"
- },
- {
- "id": 1152372226,
- "labels": ["bug"],
- "number": 2749,
- "title": "fixed typo",
- "url": "https://github.com/hapijs/joi/pull/2749"
- },
- {
- "id": 1146226674,
- "labels": ["bug"],
- "number": 2746,
- "title": "Using `Joi.attempt` with `{ convert: false }` does not prevent conversion.",
- "url": "https://github.com/hapijs/joi/issues/2746"
- },
- {
- "id": 1110310979,
- "labels": ["bug", "types"],
- "number": 2727,
- "title": "Fix validateAsync return type",
- "url": "https://github.com/hapijs/joi/pull/2727"
- },
- {
- "id": 976096206,
- "labels": ["types"],
- "number": 2663,
- "title": "Property \"local\" does not exist on type \"ErrorReport\" ",
- "url": "https://github.com/hapijs/joi/issues/2663"
- }
- ],
- "number": 180,
- "url": "https://github.com/hapijs/joi/milestone/180",
- "version": "17.6.1"
- },
- {
- "date": "2022-01-26T23:07:42Z",
- "id": 7449614,
- "issues": [
- {
- "id": 1115588030,
- "labels": ["feature"],
- "number": 2732,
- "title": "Support length() in templates",
- "url": "https://github.com/hapijs/joi/issues/2732"
- }
- ],
- "number": 179,
- "url": "https://github.com/hapijs/joi/milestone/179",
- "version": "17.6.0"
- },
- {
- "date": "2021-12-02T06:39:50Z",
- "id": 7446145,
- "issues": [
- {
- "id": 1065127444,
- "labels": ["feature"],
- "number": 2708,
- "title": "How can I define both specific error messages and a default error message?",
- "url": "https://github.com/hapijs/joi/issues/2708"
- },
- {
- "id": 1059455491,
- "labels": ["feature"],
- "number": 2706,
- "title": "Error messages do not distinguish between numbers and strings!Easily misleading",
- "url": "https://github.com/hapijs/joi/issues/2706"
- },
- {
- "id": 1053374439,
- "labels": ["types"],
- "number": 2703,
- "title": "issue #2606: pass TSchema from ObjectSchema to .validate function",
- "url": "https://github.com/hapijs/joi/pull/2703"
- },
- {
- "id": 1048657219,
- "labels": ["types"],
- "number": 2698,
- "title": "Add Date -> Joi.DateSchema map to ObjectPropertiesSchema",
- "url": "https://github.com/hapijs/joi/pull/2698"
- },
- {
- "id": 1022108922,
- "labels": ["feature"],
- "number": 2687,
- "title": "string().min(0) is failing to validate a zero-length string",
- "url": "https://github.com/hapijs/joi/issues/2687"
- },
- {
- "id": 981051830,
- "labels": ["bug"],
- "number": 2666,
- "title": "Updated `multiple` rule to support decimal/float base",
- "url": "https://github.com/hapijs/joi/pull/2666"
- },
- {
- "id": 979154463,
- "labels": ["bug", "types"],
- "number": 2665,
- "title": "Fix typings on any.external(): add helpers argument",
- "url": "https://github.com/hapijs/joi/pull/2665"
- },
- {
- "id": 962148619,
- "labels": ["bug"],
- "number": 2651,
- "title": "Fix label elimination for externals",
- "url": "https://github.com/hapijs/joi/pull/2651"
- },
- {
- "id": 958351880,
- "labels": ["bug"],
- "number": 2649,
- "title": "fix: Joi.string().hostname() not returning errors for CIDR notation",
- "url": "https://github.com/hapijs/joi/pull/2649"
- },
- {
- "id": 958349612,
- "labels": ["bug"],
- "number": 2648,
- "title": "Incorrect hostname validation",
- "url": "https://github.com/hapijs/joi/issues/2648"
- },
- {
- "id": 943251026,
- "labels": ["bug"],
- "number": 2635,
- "title": "any.external: can't disable label",
- "url": "https://github.com/hapijs/joi/issues/2635"
- },
- {
- "id": 876890865,
- "labels": ["bug", "types"],
- "number": 2605,
- "title": "\"ExternalValidationFunction\" type is missing \"helpers\" parameter in index.d.ts",
- "url": "https://github.com/hapijs/joi/issues/2605"
- },
- {
- "id": 866910880,
- "labels": ["bug"],
- "number": 2600,
- "title": "Joi.external() error message",
- "url": "https://github.com/hapijs/joi/issues/2600"
- },
- {
- "id": 846952220,
- "labels": ["bug"],
- "number": 2590,
- "title": "defaults in alternatives should work recursively",
- "url": "https://github.com/hapijs/joi/issues/2590"
- },
- {
- "id": 846945517,
- "labels": ["bug"],
- "number": 2589,
- "title": "merge subschema matches when subchemas are objects, or alternatives of objects",
- "url": "https://github.com/hapijs/joi/pull/2589"
- },
- {
- "id": 826666841,
- "labels": ["feature"],
- "number": 2577,
- "title": "add subschema property validation failures to context",
- "url": "https://github.com/hapijs/joi/pull/2577"
- }
- ],
- "number": 178,
- "url": "https://github.com/hapijs/joi/milestone/178",
- "version": "17.5.0"
- },
- {
- "date": "2021-12-01T08:48:44Z",
- "id": 7021782,
- "issues": [
- {
- "id": 1016225490,
- "labels": ["bug", "dependency"],
- "number": 2685,
- "title": "Joi.string().email() passes for `foo@bar%2ecom`",
- "url": "https://github.com/hapijs/joi/issues/2685"
- }
- ],
- "number": 177,
- "url": "https://github.com/hapijs/joi/milestone/177",
- "version": "17.4.3"
- },
- {
- "date": "2021-08-01T21:18:00Z",
- "id": 6934782,
- "issues": [
- {
- "id": 950895186,
- "labels": ["bug"],
- "number": 2642,
- "title": "Fix issue with only required items. Fixes #2620.",
- "url": "https://github.com/hapijs/joi/pull/2642"
- },
- {
- "id": 927946530,
- "labels": ["bug"],
- "number": 2624,
- "title": "Fix Web Workers compatibility",
- "url": "https://github.com/hapijs/joi/pull/2624"
- },
- {
- "id": 919358309,
- "labels": ["bug"],
- "number": 2620,
- "title": "If all elements of array is required, it does not validate unknown items",
- "url": "https://github.com/hapijs/joi/issues/2620"
- },
- {
- "id": 539748053,
- "labels": ["bug"],
- "number": 2251,
- "title": "`dist/joi-browser.min.js` doesn't work in workers",
- "url": "https://github.com/hapijs/joi/issues/2251"
- }
- ],
- "number": 176,
- "url": "https://github.com/hapijs/joi/milestone/176",
- "version": "17.4.2"
- },
- {
- "date": "2021-07-11T05:04:34Z",
- "id": 6403312,
- "issues": [
- {
- "id": 931137268,
- "labels": ["types"],
- "number": 2627,
- "title": "Add object type guards schema",
- "url": "https://github.com/hapijs/joi/pull/2627"
- },
- {
- "id": 842846439,
- "labels": ["bug", "types"],
- "number": 2586,
- "title": "fix isSchema type definition",
- "url": "https://github.com/hapijs/joi/pull/2586"
- },
- {
- "id": 842842325,
- "labels": ["bug", "types"],
- "number": 2585,
- "title": "type problem in Joi.isSchema function",
- "url": "https://github.com/hapijs/joi/issues/2585"
- },
- {
- "id": 823225132,
- "labels": ["bug", "types"],
- "number": 2573,
- "title": "Add option array type to AlternativesSchema.conditional",
- "url": "https://github.com/hapijs/joi/pull/2573"
- }
- ],
- "number": 175,
- "url": "https://github.com/hapijs/joi/milestone/175",
- "version": "17.4.1"
- },
- {
- "date": "2021-02-08T01:06:29Z",
- "id": 6026845,
- "issues": [
- {
- "id": 800384866,
- "labels": ["bug", "types"],
- "number": 2556,
- "title": "fix: any.when() options parameters not supported as Array in index.d.ts",
- "url": "https://github.com/hapijs/joi/pull/2556"
- },
- {
- "id": 800298641,
- "labels": ["bug", "types"],
- "number": 2555,
- "title": "Type definition for the function `any.when()` mismatch the documentation and usage",
- "url": "https://github.com/hapijs/joi/issues/2555"
- },
- {
- "id": 796794319,
- "labels": ["types"],
- "number": 2551,
- "title": "feat: Make Joi.Schema generic",
- "url": "https://github.com/hapijs/joi/pull/2551"
- },
- {
- "id": 795511635,
- "labels": ["bug", "feature"],
- "number": 2548,
- "title": "fix: defaults in ordered array are not filled",
- "url": "https://github.com/hapijs/joi/pull/2548"
- },
- {
- "id": 792464975,
- "labels": ["bug"],
- "number": 2543,
- "title": "URI validation, allowRelative with domain",
- "url": "https://github.com/hapijs/joi/issues/2543"
- },
- {
- "id": 781638166,
- "labels": ["bug"],
- "number": 2536,
- "title": "merge the results of a .match('all') if all the subschemas are objects",
- "url": "https://github.com/hapijs/joi/pull/2536"
- },
- {
- "id": 781603104,
- "labels": ["bug"],
- "number": 2535,
- "title": "defaults in alternatives with a match mode set are not returned",
- "url": "https://github.com/hapijs/joi/issues/2535"
- },
- {
- "id": 780582804,
- "labels": ["bug", "types"],
- "number": 2534,
- "title": "Remove incorrect errors type",
- "url": "https://github.com/hapijs/joi/pull/2534"
- },
- {
- "id": 777175773,
- "labels": ["bug"],
- "number": 2532,
- "title": "Fix confusing message when refs are passed",
- "url": "https://github.com/hapijs/joi/pull/2532"
- },
- {
- "id": 771928689,
- "labels": ["bug", "types"],
- "number": 2528,
- "title": "Added guid separator and made version optional",
- "url": "https://github.com/hapijs/joi/pull/2528"
- },
- {
- "id": 757668840,
- "labels": ["bug", "types"],
- "number": 2523,
- "title": "errors is always undefined in ValidationResult",
- "url": "https://github.com/hapijs/joi/issues/2523"
- },
- {
- "id": 757000750,
- "labels": ["bug", "types"],
- "number": 2521,
- "title": "Fix type of schema passed to alter functions",
- "url": "https://github.com/hapijs/joi/pull/2521"
- },
- {
- "id": 751579156,
- "labels": ["bug"],
- "number": 2518,
- "title": "fix for stripUnknown not working for nested object on invalid object",
- "url": "https://github.com/hapijs/joi/pull/2518"
- },
- {
- "id": 734030120,
- "labels": ["bug", "types"],
- "number": 2502,
- "title": "Appends the allowed object keys in typescript",
- "url": "https://github.com/hapijs/joi/pull/2502"
- },
- {
- "id": 715713227,
- "labels": ["bug"],
- "number": 2479,
- "title": "Inconsistency with stripUnknown: true and failing validation rules",
- "url": "https://github.com/hapijs/joi/issues/2479"
- },
- {
- "id": 707508553,
- "labels": ["bug"],
- "number": 2471,
- "title": "Joi.object().xor() throws with \"must be a string or a reference\" when passed a reference",
- "url": "https://github.com/hapijs/joi/issues/2471"
- },
- {
- "id": 691090715,
- "labels": ["bug"],
- "number": 2459,
- "title": "stripUnknown doesn't work for nested objects",
- "url": "https://github.com/hapijs/joi/issues/2459"
- },
- {
- "id": 657206357,
- "labels": ["bug"],
- "number": 2404,
- "title": "defaults in ordered array are not filled",
- "url": "https://github.com/hapijs/joi/issues/2404"
- }
- ],
- "number": 174,
- "url": "https://github.com/hapijs/joi/milestone/174",
- "version": "17.4.0"
- },
- {
- "date": "2020-10-24T07:26:46Z",
- "id": 5789852,
- "issues": [
- {
- "id": 713554250,
- "labels": ["bug", "types"],
- "number": 2477,
- "title": "Add RegExp to the supported types for Extension.type",
- "url": "https://github.com/hapijs/joi/pull/2477"
- },
- {
- "id": 713153983,
- "labels": ["bug", "types"],
- "number": 2475,
- "title": "Add render property to ReferenceOptions TS def",
- "url": "https://github.com/hapijs/joi/pull/2475"
- },
- {
- "id": 700968762,
- "labels": ["bug"],
- "number": 2465,
- "title": "@hapi/formula@2.0.0 Deprecated",
- "url": "https://github.com/hapijs/joi/issues/2465"
- },
- {
- "id": 686244539,
- "labels": ["feature"],
- "number": 2455,
- "title": "Expose prefs in external()",
- "url": "https://github.com/hapijs/joi/pull/2455"
- },
- {
- "id": 685414463,
- "labels": ["bug", "types"],
- "number": 2454,
- "title": "CustomValidator return type adjusted in typescript",
- "url": "https://github.com/hapijs/joi/pull/2454"
- },
- {
- "id": 676405382,
- "labels": ["bug", "types"],
- "number": 2442,
- "title": "Update index.d.ts",
- "url": "https://github.com/hapijs/joi/pull/2442"
- },
- {
- "id": 676264698,
- "labels": ["bug", "types"],
- "number": 2441,
- "title": "Wrong field name in ValidationError (index.d.ts)",
- "url": "https://github.com/hapijs/joi/issues/2441"
- }
- ],
- "number": 173,
- "url": "https://github.com/hapijs/joi/milestone/173",
- "version": "17.3.0"
- },
- {
- "date": "2020-08-19T16:57:59Z",
- "id": 5734564,
- "issues": [
- {
- "id": 681995650,
- "labels": ["documentation"],
- "number": 2450,
- "title": "Update dev site",
- "url": "https://github.com/hapijs/joi/issues/2450"
- }
- ],
- "number": 171,
- "url": "https://github.com/hapijs/joi/milestone/171",
- "version": "17.2.1"
- },
- {
- "date": "2020-08-05T02:12:08Z",
- "id": 5202228,
- "issues": [
- {
- "id": 673189440,
- "labels": ["types"],
- "number": 2431,
- "title": "Import types from DT",
- "url": "https://github.com/hapijs/joi/issues/2431"
- },
- {
- "id": 667115914,
- "labels": ["bug"],
- "number": 2421,
- "title": "Support ISO8601 with hours timeshift only",
- "url": "https://github.com/hapijs/joi/pull/2421"
- },
- {
- "id": 666933236,
- "labels": ["bug"],
- "number": 2419,
- "title": "isoDate doesn't recognize correct string",
- "url": "https://github.com/hapijs/joi/issues/2419"
- },
- {
- "id": 659018435,
- "labels": ["bug"],
- "number": 2408,
- "title": "Fix number padding (e.g. 00000) and trailing decimal points (e.g. 2.)",
- "url": "https://github.com/hapijs/joi/pull/2408"
- },
- {
- "id": 659003848,
- "labels": ["bug"],
- "number": 2407,
- "title": "\"2.\" throws number.unsafe",
- "url": "https://github.com/hapijs/joi/issues/2407"
- },
- {
- "id": 659000586,
- "labels": ["bug"],
- "number": 2406,
- "title": "\"00000\" throws number.unsafe",
- "url": "https://github.com/hapijs/joi/issues/2406"
- },
- {
- "id": 651179864,
- "labels": ["feature"],
- "number": 2398,
- "title": "Support maxDomainSegments",
- "url": "https://github.com/hapijs/joi/issues/2398"
- },
- {
- "id": 632975052,
- "labels": ["bug"],
- "number": 2380,
- "title": "Joi.build() does not work with complex extension bases",
- "url": "https://github.com/hapijs/joi/issues/2380"
- },
- {
- "id": 630679048,
- "labels": ["feature"],
- "number": 2377,
- "title": "Add extension validation for \"cast\"",
- "url": "https://github.com/hapijs/joi/pull/2377"
- },
- {
- "id": 611092709,
- "labels": ["feature"],
- "number": 2361,
- "title": "Validation artifacts collected from successful rules",
- "url": "https://github.com/hapijs/joi/issues/2361"
- },
- {
- "id": 598279675,
- "labels": ["bug"],
- "number": 2348,
- "title": "object.default() broke when object is extended",
- "url": "https://github.com/hapijs/joi/issues/2348"
- },
- {
- "id": 591991328,
- "labels": ["bug"],
- "number": 2337,
- "title": "tlds fails to error on invalid segment",
- "url": "https://github.com/hapijs/joi/issues/2337"
- },
- {
- "id": 589821134,
- "labels": ["bug", "feature"],
- "number": 2330,
- "title": "Consistently apply wrap setting",
- "url": "https://github.com/hapijs/joi/issues/2330"
- },
- {
- "id": 585005069,
- "labels": ["feature"],
- "number": 2320,
- "title": "invalid GUID/UUID is validated as valid",
- "url": "https://github.com/hapijs/joi/issues/2320"
- },
- {
- "id": 582564448,
- "labels": ["bug"],
- "number": 2318,
- "title": "`larger than` is incorrect for comparing quanties",
- "url": "https://github.com/hapijs/joi/issues/2318"
- },
- {
- "id": 567138401,
- "labels": ["feature"],
- "number": 2303,
- "title": "Add option to resolve `.ref()` and `.in()` values in error messages.",
- "url": "https://github.com/hapijs/joi/issues/2303"
- },
- {
- "id": 555405548,
- "labels": ["bug", "breaking changes"],
- "number": 2284,
- "title": "Array item could not be an Error",
- "url": "https://github.com/hapijs/joi/issues/2284"
- }
- ],
- "number": 170,
- "url": "https://github.com/hapijs/joi/milestone/170",
- "version": "17.2.0"
- },
- {
- "date": "2020-03-14T21:26:52Z",
- "id": 5022433,
- "issues": [
- {
- "id": 580942719,
- "labels": ["bug", "dependency"],
- "number": 2316,
- "title": "Validate domain in relative uri",
- "url": "https://github.com/hapijs/joi/issues/2316"
- },
- {
- "id": 559954254,
- "labels": ["bug"],
- "number": 2293,
- "title": "Fix error on changeless forks. Fixes #2292.",
- "url": "https://github.com/hapijs/joi/pull/2293"
- },
- {
- "id": 559901729,
- "labels": ["bug"],
- "number": 2292,
- "title": "Fork object with option already applied",
- "url": "https://github.com/hapijs/joi/issues/2292"
- }
- ],
- "number": 169,
- "url": "https://github.com/hapijs/joi/milestone/169",
- "version": "17.1.1"
- },
- {
- "date": "2020-01-20T00:03:02Z",
- "id": 4992194,
- "issues": [
- {
- "id": 552005117,
- "labels": ["feature"],
- "number": 2280,
- "title": "isError()",
- "url": "https://github.com/hapijs/joi/issues/2280"
- },
- {
- "id": 551949636,
- "labels": ["bug"],
- "number": 2279,
- "title": "Remove annotate() from assert() when used in the browser",
- "url": "https://github.com/hapijs/joi/issues/2279"
- }
- ],
- "number": 168,
- "url": "https://github.com/hapijs/joi/milestone/168",
- "version": "17.1.0"
- },
- {
- "date": "2020-01-09T18:47:40Z",
- "id": 4992167,
- "issues": [
- {
- "id": 547654883,
- "labels": ["bug"],
- "number": 2269,
- "title": "Ensure keys term always has right constructor",
- "url": "https://github.com/hapijs/joi/issues/2269"
- }
- ],
- "number": 167,
- "url": "https://github.com/hapijs/joi/milestone/167",
- "version": "17.0.2"
- },
- {
- "date": "2020-01-09T18:37:15Z",
- "id": 4979069,
- "issues": [
- {
- "id": 547649044,
- "labels": ["bug"],
- "number": 2268,
- "title": "Move flag back to proto",
- "url": "https://github.com/hapijs/joi/issues/2268"
- }
- ],
- "number": 166,
- "url": "https://github.com/hapijs/joi/milestone/166",
- "version": "17.0.1"
- },
- {
- "date": "2020-01-06T19:40:08Z",
- "id": 4797017,
- "issues": [
- {
- "id": 545259143,
- "labels": ["dependency"],
- "number": 2263,
- "title": "Update deps",
- "url": "https://github.com/hapijs/joi/issues/2263"
- },
- {
- "id": 545258955,
- "labels": ["breaking changes", "release notes"],
- "number": 2262,
- "title": "17.0.0 Release Notes",
- "url": "https://github.com/hapijs/joi/issues/2262"
- },
- {
- "id": 545243016,
- "labels": ["breaking changes"],
- "number": 2261,
- "title": "Remove ValidationError.annotate() from browser build",
- "url": "https://github.com/hapijs/joi/issues/2261"
- },
- {
- "id": 545220874,
- "labels": ["feature"],
- "number": 2260,
- "title": "object.regex()",
- "url": "https://github.com/hapijs/joi/issues/2260"
- },
- {
- "id": 542077557,
- "labels": ["bug"],
- "number": 2254,
- "title": "Giving an array argument to any.valid returns incorrect error",
- "url": "https://github.com/hapijs/joi/issues/2254"
- },
- {
- "id": 535937306,
- "labels": ["bug"],
- "number": 2243,
- "title": "Allow `_` in alias, arg, flag, modifier, override, rule, and term names",
- "url": "https://github.com/hapijs/joi/pull/2243"
- },
- {
- "id": 535769742,
- "labels": ["bug"],
- "number": 2242,
- "title": "Can you allow `_` in rule names?",
- "url": "https://github.com/hapijs/joi/issues/2242"
- },
- {
- "id": 529698356,
- "labels": ["breaking changes"],
- "number": 2231,
- "title": "Change errors.wrapArrays to errors.wrap.array",
- "url": "https://github.com/hapijs/joi/issues/2231"
- },
- {
- "id": 522427823,
- "labels": ["feature"],
- "number": 2219,
- "title": "Add the ability to extend all types in place",
- "url": "https://github.com/hapijs/joi/issues/2219"
- },
- {
- "id": 514306299,
- "labels": ["non issue"],
- "number": 2200,
- "title": "Move ip and uri logic to address",
- "url": "https://github.com/hapijs/joi/issues/2200"
- },
- {
- "id": 514305737,
- "labels": ["breaking changes", "dependency"],
- "number": 2199,
- "title": "Remove node 8, 10",
- "url": "https://github.com/hapijs/joi/issues/2199"
- },
- {
- "id": 509090188,
- "labels": ["feature", "breaking changes"],
- "number": 2189,
- "title": "Change default function second argument to full helpers (from prefs)",
- "url": "https://github.com/hapijs/joi/issues/2189"
- },
- {
- "id": 507538924,
- "labels": ["feature", "breaking changes"],
- "number": 2182,
- "title": "Remove quotation marks from error messages",
- "url": "https://github.com/hapijs/joi/issues/2182"
- },
- {
- "id": 501937158,
- "labels": ["feature"],
- "number": 2163,
- "title": "string().hostiname() - validation of non-ASCII chars containing domains",
- "url": "https://github.com/hapijs/joi/issues/2163"
- }
- ],
- "number": 164,
- "url": "https://github.com/hapijs/joi/milestone/164",
- "version": "17.0.0"
- },
- {
- "date": "2019-11-24T10:02:03Z",
- "id": 4724216,
- "issues": [
- {
- "id": 526516921,
- "labels": ["bug"],
- "number": 2226,
- "title": "object.with and object.without throw error on $ prefixed keys",
- "url": "https://github.com/hapijs/joi/issues/2226"
- },
- {
- "id": 522065305,
- "labels": ["bug"],
- "number": 2218,
- "title": "Maximum call stack size exceeded error for dataUri validation",
- "url": "https://github.com/hapijs/joi/issues/2218"
- },
- {
- "id": 518514150,
- "labels": ["bug"],
- "number": 2212,
- "title": "Joi.string().email() considers \"a@a.com/asd\" as valid email",
- "url": "https://github.com/hapijs/joi/issues/2212"
- },
- {
- "id": 517182026,
- "labels": ["bug"],
- "number": 2208,
- "title": "fix: describe() on schema with default value null",
- "url": "https://github.com/hapijs/joi/pull/2208"
- },
- {
- "id": 517156454,
- "labels": ["bug"],
- "number": 2207,
- "title": "describe() on schema with default value null results in \"Cannot read property 'Symbol(literal)' of null\"",
- "url": "https://github.com/hapijs/joi/issues/2207"
- },
- {
- "id": 515547271,
- "labels": ["bug"],
- "number": 2205,
- "title": "Cannot require a minimal number of matching object properties with `pattern`",
- "url": "https://github.com/hapijs/joi/issues/2205"
- },
- {
- "id": 509557279,
- "labels": ["bug"],
- "number": 2190,
- "title": "Joi.string().domain() treats an email address as a valid domain name",
- "url": "https://github.com/hapijs/joi/issues/2190"
- },
- {
- "id": 508598304,
- "labels": ["bug"],
- "number": 2187,
- "title": "Giving an array argument to any.allow(...values) gives incorrect error",
- "url": "https://github.com/hapijs/joi/issues/2187"
- },
- {
- "id": 506899409,
- "labels": ["non issue"],
- "number": 2181,
- "title": " Joi.alternatives produces confusing message when used with nested object and `{ abortEarly: false }`",
- "url": "https://github.com/hapijs/joi/issues/2181"
- },
- {
- "id": 506282593,
- "labels": ["bug"],
- "number": 2176,
- "title": "joi.types() is missing `func` alias",
- "url": "https://github.com/hapijs/joi/issues/2176"
- },
- {
- "id": 504105644,
- "labels": ["documentation", "support"],
- "number": 2173,
- "title": "[Request] Allow mixing patch version",
- "url": "https://github.com/hapijs/joi/issues/2173"
- }
- ],
- "number": 163,
- "url": "https://github.com/hapijs/joi/milestone/163",
- "version": "16.1.8"
- },
- {
- "date": "2019-10-05T17:37:42Z",
- "id": 4723324,
- "issues": [
- {
- "id": 502992707,
- "labels": ["bug"],
- "number": 2168,
- "title": "Date fails to enforce format when value is a number string",
- "url": "https://github.com/hapijs/joi/issues/2168"
- }
- ],
- "number": 162,
- "url": "https://github.com/hapijs/joi/milestone/162",
- "version": "16.1.7"
- },
- {
- "date": "2019-10-05T03:41:01Z",
- "id": 4712266,
- "issues": [
- {
- "id": 502861807,
- "labels": ["bug"],
- "number": 2167,
- "title": "Error.captureStackTrace can't be used in all browser builds",
- "url": "https://github.com/hapijs/joi/issues/2167"
- },
- {
- "id": 502462420,
- "labels": ["bug"],
- "number": 2165,
- "title": "Cannot read property 'delete' of undefined",
- "url": "https://github.com/hapijs/joi/issues/2165"
- }
- ],
- "number": 161,
- "url": "https://github.com/hapijs/joi/milestone/161",
- "version": "16.1.6"
- },
- {
- "date": "2019-10-02T07:36:01Z",
- "id": 4678539,
- "issues": [
- {
- "id": 499817149,
- "labels": ["bug"],
- "number": 2156,
- "title": "node.get is not a function when validating",
- "url": "https://github.com/hapijs/joi/issues/2156"
- },
- {
- "id": 498227884,
- "labels": ["bug"],
- "number": 2147,
- "title": "Joi v16: TypeError issue with valid(Joi.ref(x)).error()",
- "url": "https://github.com/hapijs/joi/issues/2147"
- }
- ],
- "number": 160,
- "url": "https://github.com/hapijs/joi/milestone/160",
- "version": "16.1.5"
- },
- {
- "date": "2019-09-20T22:14:42Z",
- "id": 4678511,
- "issues": [
- {
- "id": 496526120,
- "labels": ["bug"],
- "number": 2134,
- "title": "Joi.any().default(