joi 17.7.0 → 17.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/joi-browser.min.js +1 -1
- package/lib/annotate.js +1 -1
- package/lib/base.js +4 -4
- package/lib/cache.js +2 -2
- package/lib/common.js +2 -2
- package/lib/compile.js +1 -1
- package/lib/extend.js +2 -2
- package/lib/index.d.ts +14 -3
- package/lib/index.js +2 -2
- package/lib/manifest.js +2 -2
- package/lib/messages.js +2 -2
- package/lib/modify.js +1 -1
- package/lib/ref.js +3 -3
- package/lib/state.js +2 -2
- package/lib/template.js +4 -4
- package/lib/trace.js +2 -2
- package/lib/types/alternatives.js +2 -2
- package/lib/types/any.js +1 -1
- package/lib/types/array.js +3 -3
- package/lib/types/binary.js +1 -1
- package/lib/types/boolean.js +1 -1
- package/lib/types/date.js +1 -1
- package/lib/types/function.js +1 -1
- package/lib/types/keys.js +3 -3
- package/lib/types/link.js +1 -1
- package/lib/types/number.js +1 -1
- package/lib/types/string.js +14 -17
- package/lib/types/symbol.js +1 -1
- package/lib/validator.js +4 -4
- package/lib/values.js +2 -2
- package/package.json +10 -9
package/lib/annotate.js
CHANGED
package/lib/base.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const Clone = require('@hapi/hoek/
|
|
5
|
-
const DeepEqual = require('@hapi/hoek/
|
|
6
|
-
const Merge = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const Clone = require('@hapi/hoek/clone');
|
|
5
|
+
const DeepEqual = require('@hapi/hoek/deepEqual');
|
|
6
|
+
const Merge = require('@hapi/hoek/merge');
|
|
7
7
|
|
|
8
8
|
const Cache = require('./cache');
|
|
9
9
|
const Common = require('./common');
|
package/lib/cache.js
CHANGED
package/lib/common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const AssertError = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const AssertError = require('@hapi/hoek/assertError');
|
|
5
5
|
|
|
6
6
|
const Pkg = require('../package.json');
|
|
7
7
|
|
package/lib/compile.js
CHANGED
package/lib/extend.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const Clone = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const Clone = require('@hapi/hoek/clone');
|
|
5
5
|
|
|
6
6
|
const Common = require('./common');
|
|
7
7
|
const Messages = require('./messages');
|
package/lib/index.d.ts
CHANGED
|
@@ -290,6 +290,12 @@ declare namespace Joi {
|
|
|
290
290
|
* @default true
|
|
291
291
|
*/
|
|
292
292
|
allowUnicode?: boolean;
|
|
293
|
+
/**
|
|
294
|
+
* If `true`, underscores (`_`) are allowed in the domain name
|
|
295
|
+
*
|
|
296
|
+
* @default false
|
|
297
|
+
*/
|
|
298
|
+
allowUnderscore?: boolean;
|
|
293
299
|
/**
|
|
294
300
|
* if `true`, ignore invalid email length errors.
|
|
295
301
|
*
|
|
@@ -341,7 +347,12 @@ declare namespace Joi {
|
|
|
341
347
|
* @default true
|
|
342
348
|
*/
|
|
343
349
|
allowUnicode?: boolean;
|
|
344
|
-
|
|
350
|
+
/**
|
|
351
|
+
* If `true`, underscores (`_`) are allowed in the domain name
|
|
352
|
+
*
|
|
353
|
+
* @default false
|
|
354
|
+
*/
|
|
355
|
+
allowUnderscore?: boolean;
|
|
345
356
|
/**
|
|
346
357
|
* 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)
|
|
347
358
|
*
|
|
@@ -1328,7 +1339,7 @@ declare namespace Joi {
|
|
|
1328
1339
|
* see `boolean.sensitive()` to change this behavior.
|
|
1329
1340
|
* @param values - strings, numbers or arrays of them
|
|
1330
1341
|
*/
|
|
1331
|
-
falsy(...values: Array<string | number>): this;
|
|
1342
|
+
falsy(...values: Array<string | number | null>): this;
|
|
1332
1343
|
|
|
1333
1344
|
/**
|
|
1334
1345
|
* Allows the values provided to truthy and falsy as well as the "true" and "false" default conversion
|
|
@@ -1341,7 +1352,7 @@ declare namespace Joi {
|
|
|
1341
1352
|
* String comparisons are by default case insensitive, see `boolean.sensitive()` to change this behavior.
|
|
1342
1353
|
* @param values - strings, numbers or arrays of them
|
|
1343
1354
|
*/
|
|
1344
|
-
truthy(...values: Array<string | number>): this;
|
|
1355
|
+
truthy(...values: Array<string | number | null>): this;
|
|
1345
1356
|
}
|
|
1346
1357
|
|
|
1347
1358
|
interface NumberSchema<TSchema = number> extends AnySchema<TSchema> {
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const Clone = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const Clone = require('@hapi/hoek/clone');
|
|
5
5
|
|
|
6
6
|
const Cache = require('./cache');
|
|
7
7
|
const Common = require('./common');
|
package/lib/manifest.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const Clone = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const Clone = require('@hapi/hoek/clone');
|
|
5
5
|
|
|
6
6
|
const Common = require('./common');
|
|
7
7
|
const Messages = require('./messages');
|
package/lib/messages.js
CHANGED
package/lib/modify.js
CHANGED
package/lib/ref.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const Clone = require('@hapi/hoek/
|
|
5
|
-
const Reach = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const Clone = require('@hapi/hoek/clone');
|
|
5
|
+
const Reach = require('@hapi/hoek/reach');
|
|
6
6
|
|
|
7
7
|
const Common = require('./common');
|
|
8
8
|
|
package/lib/state.js
CHANGED
package/lib/template.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const Clone = require('@hapi/hoek/
|
|
5
|
-
const EscapeHtml = require('@hapi/hoek/
|
|
6
|
-
const Formula = require('@
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const Clone = require('@hapi/hoek/clone');
|
|
5
|
+
const EscapeHtml = require('@hapi/hoek/escapeHtml');
|
|
6
|
+
const Formula = require('@hapi/formula');
|
|
7
7
|
|
|
8
8
|
const Common = require('./common');
|
|
9
9
|
const Errors = require('./errors');
|
package/lib/trace.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const Merge = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const Merge = require('@hapi/hoek/merge');
|
|
5
5
|
|
|
6
6
|
const Any = require('./any');
|
|
7
7
|
const Common = require('../common');
|
package/lib/types/any.js
CHANGED
package/lib/types/array.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const DeepEqual = require('@hapi/hoek/
|
|
5
|
-
const Reach = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const DeepEqual = require('@hapi/hoek/deepEqual');
|
|
5
|
+
const Reach = require('@hapi/hoek/reach');
|
|
6
6
|
|
|
7
7
|
const Any = require('./any');
|
|
8
8
|
const Common = require('../common');
|
package/lib/types/binary.js
CHANGED
package/lib/types/boolean.js
CHANGED
package/lib/types/date.js
CHANGED
package/lib/types/function.js
CHANGED
package/lib/types/keys.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const ApplyToDefaults = require('@hapi/hoek/
|
|
4
|
-
const Assert = require('@hapi/hoek/
|
|
5
|
-
const Clone = require('@hapi/hoek/
|
|
3
|
+
const ApplyToDefaults = require('@hapi/hoek/applyToDefaults');
|
|
4
|
+
const Assert = require('@hapi/hoek/assert');
|
|
5
|
+
const Clone = require('@hapi/hoek/clone');
|
|
6
6
|
const Topo = require('@hapi/topo');
|
|
7
7
|
|
|
8
8
|
const Any = require('./any');
|
package/lib/types/link.js
CHANGED
package/lib/types/number.js
CHANGED
package/lib/types/string.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const EscapeRegex = require('@hapi/hoek/lib/escapeRegex');
|
|
8
|
-
const Tlds = require('@sideway/address/lib/tlds');
|
|
9
|
-
const Uri = require('@sideway/address/lib/uri');
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const { isDomainValid, isEmailValid, ipRegex, uriRegex } = require('@hapi/address');
|
|
5
|
+
const EscapeRegex = require('@hapi/hoek/escapeRegex');
|
|
6
|
+
const Tlds = require('@hapi/tlds');
|
|
10
7
|
|
|
11
8
|
const Any = require('./any');
|
|
12
9
|
const Common = require('../common');
|
|
13
10
|
|
|
14
11
|
|
|
15
12
|
const internals = {
|
|
16
|
-
tlds: Tlds instanceof Set ? { tlds: { allow: Tlds, deny: null } } : false, // $lab:coverage:ignore$
|
|
13
|
+
tlds: Tlds.tlds instanceof Set ? { tlds: { allow: Tlds.tlds, deny: null } } : false, // $lab:coverage:ignore$
|
|
17
14
|
base64Regex: {
|
|
18
15
|
// paddingRequired
|
|
19
16
|
true: {
|
|
@@ -28,7 +25,7 @@ const internals = {
|
|
|
28
25
|
},
|
|
29
26
|
dataUriRegex: /^data:[\w+.-]+\/[\w+.-]+;((charset=[\w-]+|base64),)?(.*)$/,
|
|
30
27
|
hexRegex: /^[a-f0-9]+$/i,
|
|
31
|
-
ipRegex:
|
|
28
|
+
ipRegex: ipRegex({ cidr: 'forbidden' }).regex,
|
|
32
29
|
isoDurationRegex: /^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/,
|
|
33
30
|
|
|
34
31
|
guidBrackets: {
|
|
@@ -264,7 +261,7 @@ module.exports = Any.extend({
|
|
|
264
261
|
method(options) {
|
|
265
262
|
|
|
266
263
|
if (options) {
|
|
267
|
-
Common.assertOptions(options, ['allowFullyQualified', 'allowUnicode', 'maxDomainSegments', 'minDomainSegments', 'tlds']);
|
|
264
|
+
Common.assertOptions(options, ['allowFullyQualified', 'allowUnicode', 'allowUnderscore', 'maxDomainSegments', 'minDomainSegments', 'tlds']);
|
|
268
265
|
}
|
|
269
266
|
|
|
270
267
|
const address = internals.addressOptions(options);
|
|
@@ -272,7 +269,7 @@ module.exports = Any.extend({
|
|
|
272
269
|
},
|
|
273
270
|
validate(value, helpers, args, { address }) {
|
|
274
271
|
|
|
275
|
-
if (
|
|
272
|
+
if (isDomainValid(value, address)) {
|
|
276
273
|
return value;
|
|
277
274
|
}
|
|
278
275
|
|
|
@@ -296,7 +293,7 @@ module.exports = Any.extend({
|
|
|
296
293
|
const emails = options.multiple ? value.split(regex) : [value];
|
|
297
294
|
const invalids = [];
|
|
298
295
|
for (const email of emails) {
|
|
299
|
-
if (!
|
|
296
|
+
if (!isEmailValid(email, address)) {
|
|
300
297
|
invalids.push(email);
|
|
301
298
|
}
|
|
302
299
|
}
|
|
@@ -395,7 +392,7 @@ module.exports = Any.extend({
|
|
|
395
392
|
},
|
|
396
393
|
validate(value, helpers) {
|
|
397
394
|
|
|
398
|
-
if (
|
|
395
|
+
if (isDomainValid(value, { minDomainSegments: 1 }) ||
|
|
399
396
|
internals.ipRegex.test(value)) {
|
|
400
397
|
|
|
401
398
|
return value;
|
|
@@ -417,7 +414,7 @@ module.exports = Any.extend({
|
|
|
417
414
|
|
|
418
415
|
Common.assertOptions(options, ['cidr', 'version']);
|
|
419
416
|
|
|
420
|
-
const { cidr, versions, regex } =
|
|
417
|
+
const { cidr, versions, regex } = ipRegex(options);
|
|
421
418
|
const version = options.version ? versions : undefined;
|
|
422
419
|
return this.$_addRule({ name: 'ip', args: { options: { cidr, version } }, regex });
|
|
423
420
|
},
|
|
@@ -642,7 +639,7 @@ module.exports = Any.extend({
|
|
|
642
639
|
Common.assertOptions(options.domain, ['allowFullyQualified', 'allowUnicode', 'maxDomainSegments', 'minDomainSegments', 'tlds']);
|
|
643
640
|
}
|
|
644
641
|
|
|
645
|
-
const { regex, scheme } =
|
|
642
|
+
const { regex, scheme } = uriRegex(options);
|
|
646
643
|
const domain = options.domain ? internals.addressOptions(options.domain) : null;
|
|
647
644
|
return this.$_addRule({ name: 'uri', args: { options }, regex, domain, scheme });
|
|
648
645
|
},
|
|
@@ -657,7 +654,7 @@ module.exports = Any.extend({
|
|
|
657
654
|
const matched = match[1] || match[2];
|
|
658
655
|
if (domain &&
|
|
659
656
|
(!options.allowRelative || matched) &&
|
|
660
|
-
!
|
|
657
|
+
!isDomainValid(matched, domain)) {
|
|
661
658
|
|
|
662
659
|
return helpers.error('string.domain', { value: matched });
|
|
663
660
|
}
|
|
@@ -796,7 +793,7 @@ internals.addressOptions = function (options) {
|
|
|
796
793
|
internals.validateTlds = function (set, source) {
|
|
797
794
|
|
|
798
795
|
for (const tld of set) {
|
|
799
|
-
Assert(
|
|
796
|
+
Assert(isDomainValid(tld, { minDomainSegments: 1, maxDomainSegments: 1 }), `${source} must contain valid top level domain names`);
|
|
800
797
|
}
|
|
801
798
|
};
|
|
802
799
|
|
package/lib/types/symbol.js
CHANGED
package/lib/validator.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const Clone = require('@hapi/hoek/
|
|
5
|
-
const Ignore = require('@hapi/hoek/
|
|
6
|
-
const Reach = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const Clone = require('@hapi/hoek/clone');
|
|
5
|
+
const Ignore = require('@hapi/hoek/ignore');
|
|
6
|
+
const Reach = require('@hapi/hoek/reach');
|
|
7
7
|
|
|
8
8
|
const Common = require('./common');
|
|
9
9
|
const Errors = require('./errors');
|
package/lib/values.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Assert = require('@hapi/hoek/
|
|
4
|
-
const DeepEqual = require('@hapi/hoek/
|
|
3
|
+
const Assert = require('@hapi/hoek/assert');
|
|
4
|
+
const DeepEqual = require('@hapi/hoek/deepEqual');
|
|
5
5
|
|
|
6
6
|
const Common = require('./common');
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "joi",
|
|
3
3
|
"description": "Object schema validation",
|
|
4
|
-
"version": "17.
|
|
4
|
+
"version": "17.8.0",
|
|
5
5
|
"repository": "git://github.com/hapijs/joi",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -15,17 +15,18 @@
|
|
|
15
15
|
"validation"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@hapi/hoek": "^
|
|
19
|
-
"@hapi/
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
18
|
+
"@hapi/hoek": "^11.0.2",
|
|
19
|
+
"@hapi/tlds": "^1.0.1",
|
|
20
|
+
"@hapi/topo": "^6.0.1",
|
|
21
|
+
"@hapi/address": "^5.1.0",
|
|
22
|
+
"@hapi/pinpoint": "^2.0.1",
|
|
23
|
+
"@hapi/formula": "^3.0.2"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@hapi/bourne": "
|
|
26
|
-
"@hapi/code": "
|
|
26
|
+
"@hapi/bourne": "^3.0.0",
|
|
27
|
+
"@hapi/code": "^9.0.3",
|
|
27
28
|
"@hapi/joi-legacy-test": "npm:@hapi/joi@15.x.x",
|
|
28
|
-
"@hapi/lab": "^25.
|
|
29
|
+
"@hapi/lab": "^25.1.2",
|
|
29
30
|
"@types/node": "^14.18.24",
|
|
30
31
|
"typescript": "4.3.x"
|
|
31
32
|
},
|