Comparing version 17.11.1 to 17.12.0
@@ -30,3 +30,7 @@ 'use strict'; | ||
dataUriRegex: /^data:[\w+.-]+\/[\w+.-]+;((charset=[\w-]+|base64),)?(.*)$/, | ||
hexRegex: /^[a-f0-9]+$/i, | ||
hexRegex: { | ||
withPrefix: /^0x[0-9a-f]+$/i, | ||
withOptionalPrefix: /^(?:0x)?[0-9a-f]+$/i, | ||
withoutPrefix: /^[0-9a-f]+$/i | ||
}, | ||
ipRegex: Ip.regex({ cidr: 'forbidden' }).regex, | ||
@@ -372,6 +376,7 @@ isoDurationRegex: /^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/, | ||
Common.assertOptions(options, ['byteAligned']); | ||
Common.assertOptions(options, ['byteAligned', 'prefix']); | ||
options = { byteAligned: false, ...options }; | ||
options = { byteAligned: false, prefix: false, ...options }; | ||
Assert(typeof options.byteAligned === 'boolean', 'byteAligned must be boolean'); | ||
Assert(typeof options.prefix === 'boolean' || options.prefix === 'optional', 'prefix must be boolean or "optional"'); | ||
@@ -382,3 +387,8 @@ return this.$_addRule({ name: 'hex', args: { options } }); | ||
if (!internals.hexRegex.test(value)) { | ||
const re = options.prefix === 'optional' ? | ||
internals.hexRegex.withOptionalPrefix : | ||
options.prefix === true ? | ||
internals.hexRegex.withPrefix : | ||
internals.hexRegex.withoutPrefix; | ||
if (!re.test(value)) { | ||
return helpers.error('string.hex'); | ||
@@ -385,0 +395,0 @@ } |
{ | ||
"name": "joi", | ||
"description": "Object schema validation", | ||
"version": "17.11.1", | ||
"version": "17.12.0", | ||
"repository": "git://github.com/hapijs/joi", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
530255
9896