jsonpolice
Advanced tools
Comparing version 9.0.0 to 10.0.0
@@ -258,3 +258,24 @@ "use strict"; | ||
} | ||
// TODO validate format | ||
switch (spec.format) { | ||
case 'date': | ||
case 'date-time': | ||
if (!(0, utils_1.testRegExp)(spec.format, data)) { | ||
throw Schema.error(spec, 'format'); | ||
} | ||
else { | ||
return new Date(data); | ||
} | ||
case 'time': | ||
case 'email': | ||
case 'hostname': | ||
case 'ipv4': | ||
case 'ipv6': | ||
case 'uri': | ||
if (!(0, utils_1.testRegExp)(spec.format, data)) { | ||
throw Schema.error(spec, 'format'); | ||
} | ||
else { | ||
return data; | ||
} | ||
} | ||
} | ||
@@ -261,0 +282,0 @@ return data; |
@@ -13,2 +13,4 @@ "use strict"; | ||
const defaultREs = { | ||
date: /^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/, | ||
time: /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?$/, | ||
'date-time': /^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$/, | ||
@@ -20,3 +22,3 @@ email: /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, | ||
uri: /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/, | ||
semver: /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+[0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*)?$/ | ||
semver: /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+[0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*)?$/, | ||
}; | ||
@@ -23,0 +25,0 @@ const cachedREs = {}; |
{ | ||
"name": "jsonpolice", | ||
"version": "9.0.0", | ||
"version": "10.0.0", | ||
"description": "JSON Schema parser and validator", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
43874
871