Skip to content

Commit a3ea498

Browse files
author
Sascha Goldhofer
committed
release: bump version to v9.0.3
1 parent 1579e54 commit a3ea498

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

dist/jsonSchemaLibrary.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/module/lib/validation/format.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const isValidIPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\
99
const isValidIPV6 = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;
1010
const isValidHostname = /^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/;
1111
const matchDate = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
12-
const matchTime = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
12+
// const matchTime = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
13+
const matchTime = /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i;
1314
const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
1415
const isValidJsonPointer = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
1516
const isValidRelativeJsonPointer = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
@@ -144,25 +145,31 @@ const formatValidators = {
144145
}
145146
return errors.formatRegExError({ value, pointer, schema });
146147
},
148+
// hh:mm:ss.sTZD
149+
// https://opis.io/json-schema/2.x/formats.html
150+
// regex https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s07.html
147151
time: (draft, schema, value, pointer) => {
148152
if (typeof value !== "string" || value === "") {
149153
return undefined;
150154
}
151155
// https://github.com/cfworker/cfworker/blob/main/packages/json-schema/src/format.ts
152156
const matches = value.match(matchTime);
153-
if (!matches) {
154-
return errors.formatDateTimeError({ value, pointer, schema });
155-
}
156-
const hour = +matches[1];
157-
const minute = +matches[2];
158-
const second = +matches[3];
159-
const timeZone = !!matches[5];
160-
if (((hour <= 23 && minute <= 59 && second <= 59) ||
161-
(hour == 23 && minute == 59 && second == 60)) &&
162-
timeZone) {
163-
return undefined;
164-
}
165-
return errors.formatTimeError({ value, pointer, schema });
157+
return matches ? undefined : errors.formatDateTimeError({ value, pointer, schema });
158+
// if (!matches) {
159+
// return errors.formatDateTimeError({ value, pointer, schema });
160+
// }
161+
// const hour = +matches[1];
162+
// const minute = +matches[2];
163+
// const second = +matches[3];
164+
// const timeZone = !!matches[5];
165+
// if (
166+
// ((hour <= 23 && minute <= 59 && second <= 59) ||
167+
// (hour == 23 && minute == 59 && second == 60)) &&
168+
// timeZone
169+
// ) {
170+
// return undefined;
171+
// }
172+
// return errors.formatTimeError({ value, pointer, schema });
166173
},
167174
uri: (draft, schema, value, pointer) => {
168175
if (typeof value !== "string" || value === "") {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-schema-library",
3-
"version": "9.0.2",
3+
"version": "9.0.3",
44
"description": "Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation",
55
"module": "dist/module/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)