Skip to content

Commit d755083

Browse files
author
Sascha Goldhofer
committed
release: bump version to v9.1.2
1 parent a570d3c commit d755083

File tree

4 files changed

+30
-34
lines changed

4 files changed

+30
-34
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/features/anyOf.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @draft-04
33
*/
44
import { mergeSchema } from "../mergeSchema";
5-
import errors from "../validation/errors";
65
import { omit } from "../utils/omit";
76
/**
87
* returns merged schema of all valid anyOf subschemas for the given input data.
@@ -34,7 +33,7 @@ export function resolveAnyOf(draft, data, schema = draft.rootSchema, pointer = "
3433
}
3534
const resolvedSchema = mergeValidAnyOfSchema(draft, schema, data);
3635
if (resolvedSchema == null) {
37-
return errors.anyOfError({ pointer, schema, value: data, anyOf: JSON.stringify(anyOf) });
36+
return draft.errors.anyOfError({ pointer, schema, value: data, anyOf: JSON.stringify(anyOf) });
3837
}
3938
const mergedSchema = mergeSchema(schema, resolvedSchema);
4039
return omit(mergedSchema, "anyOf");

dist/module/lib/step.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import getTypeOf from "./getTypeOf";
22
import createSchemaOf from "./createSchemaOf";
3-
import errors from "./validation/errors";
43
import { isJsonError } from "./types";
54
import { reduceSchema } from "./reduceSchema";
65
const stepType = {
@@ -19,7 +18,7 @@ const stepType = {
1918
}
2019
// @draft >= 7 bool schema, items:[true, false]
2120
if (schema.items[key] === false) {
22-
return errors.invalidDataError({
21+
return draft.errors.invalidDataError({
2322
key,
2423
value: itemValue,
2524
pointer,
@@ -30,7 +29,7 @@ const stepType = {
3029
return draft.resolveRef(schema.items[key]);
3130
}
3231
if (schema.additionalItems === false) {
33-
return errors.additionalItemsError({
32+
return draft.errors.additionalItemsError({
3433
key,
3534
value: itemValue,
3635
pointer,
@@ -61,7 +60,7 @@ const stepType = {
6160
// @todo patternProperties also validate properties
6261
// @feature boolean schema
6362
if (property === false) {
64-
return errors.forbiddenPropertyError({
63+
return draft.errors.forbiddenPropertyError({
6564
property: key,
6665
value: data,
6766
pointer,
@@ -107,7 +106,7 @@ const stepType = {
107106
if (data && (additionalProperties === undefined || additionalProperties === true)) {
108107
return createSchemaOf(data[key]);
109108
}
110-
return errors.unknownPropertyError({
109+
return draft.errors.unknownPropertyError({
111110
property: key,
112111
value: data,
113112
pointer: `${pointer}`,

dist/module/lib/validation/format.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable max-len, no-control-regex */
2-
import errors from "./errors";
31
import validUrl from "valid-url";
42
import { parse as parseIdnEmail } from "smtp-address-parser";
53
// referenced
@@ -28,7 +26,7 @@ const formatValidators = {
2826
// full-date from http://tools.ietf.org/html/rfc3339#section-5.6
2927
const matches = value.match(matchDate);
3028
if (!matches) {
31-
return errors.formatDateTimeError({ value, pointer, schema });
29+
return draft.errors.formatDateTimeError({ value, pointer, schema });
3230
}
3331
const year = +matches[1];
3432
const month = +matches[2];
@@ -41,40 +39,40 @@ const formatValidators = {
4139
day <= (month == 2 && isLeapYear ? 29 : DAYS[month])) {
4240
return undefined;
4341
}
44-
return errors.formatDateError({ value, pointer, schema });
42+
return draft.errors.formatDateError({ value, pointer, schema });
4543
},
4644
"date-time": (draft, schema, value, pointer) => {
4745
if (typeof value !== "string" || value === "") {
4846
return undefined;
4947
}
5048
if (value === "" || isValidDateTime.test(value)) {
5149
if (new Date(value).toString() === "Invalid Date") {
52-
return errors.formatDateTimeError({ value, pointer, schema });
50+
return draft.errors.formatDateTimeError({ value, pointer, schema });
5351
}
5452
return undefined;
5553
}
56-
return errors.formatDateTimeError({ value, pointer, schema });
54+
return draft.errors.formatDateTimeError({ value, pointer, schema });
5755
},
5856
email: (draft, schema, value, pointer) => {
5957
if (typeof value !== "string" || value === "") {
6058
return undefined;
6159
}
6260
// taken from https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
6361
if (value[0] === '"') {
64-
return errors.formatEmailError({ value, pointer, schema });
62+
return draft.errors.formatEmailError({ value, pointer, schema });
6563
}
6664
const [name, host, ...rest] = value.split("@");
6765
if (!name || !host || rest.length !== 0 || name.length > 64 || host.length > 253) {
68-
return errors.formatEmailError({ value, pointer, schema });
66+
return draft.errors.formatEmailError({ value, pointer, schema });
6967
}
7068
if (name[0] === "." || name.endsWith(".") || name.includes("..")) {
71-
return errors.formatEmailError({ value, pointer, schema });
69+
return draft.errors.formatEmailError({ value, pointer, schema });
7270
}
7371
if (!/^[a-z0-9.-]+$/i.test(host) || !/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(name)) {
74-
return errors.formatEmailError({ value, pointer, schema });
72+
return draft.errors.formatEmailError({ value, pointer, schema });
7573
}
7674
if (!host.split(".").every((part) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part))) {
77-
return errors.formatEmailError({ value, pointer, schema });
75+
return draft.errors.formatEmailError({ value, pointer, schema });
7876
}
7977
return undefined;
8078
},
@@ -91,7 +89,7 @@ const formatValidators = {
9189
return undefined;
9290
}
9391
catch (e) {
94-
return errors.formatEmailError({ value, pointer, schema });
92+
return draft.errors.formatEmailError({ value, pointer, schema });
9593
}
9694
},
9795
hostname: (draft, schema, value, pointer) => {
@@ -101,33 +99,33 @@ const formatValidators = {
10199
if (value === "" || isValidHostname.test(value)) {
102100
return undefined;
103101
}
104-
return errors.formatHostnameError({ value, pointer, schema });
102+
return draft.errors.formatHostnameError({ value, pointer, schema });
105103
},
106104
ipv4: (draft, schema, value, pointer) => {
107105
if (typeof value !== "string" || value === "") {
108106
return undefined;
109107
}
110108
if (value && value[0] === "0") {
111109
// leading zeroes should be rejected, as they are treated as octals
112-
return errors.formatIPV4LeadingZeroError({ value, pointer, schema });
110+
return draft.errors.formatIPV4LeadingZeroError({ value, pointer, schema });
113111
}
114112
if (value.length <= 15 && isValidIPV4.test(value)) {
115113
return undefined;
116114
}
117-
return errors.formatIPV4Error({ value, pointer, schema });
115+
return draft.errors.formatIPV4Error({ value, pointer, schema });
118116
},
119117
ipv6: (draft, schema, value, pointer) => {
120118
if (typeof value !== "string" || value === "") {
121119
return undefined;
122120
}
123121
if (value && value[0] === "0") {
124122
// leading zeroes should be rejected, as they are treated as octals
125-
return errors.formatIPV6LeadingZeroError({ value, pointer, schema });
123+
return draft.errors.formatIPV6LeadingZeroError({ value, pointer, schema });
126124
}
127125
if (value.length <= 45 && isValidIPV6.test(value)) {
128126
return undefined;
129127
}
130-
return errors.formatIPV6Error({ value, pointer, schema });
128+
return draft.errors.formatIPV6Error({ value, pointer, schema });
131129
},
132130
"json-pointer": (draft, schema, value, pointer) => {
133131
if (typeof value !== "string" || value === "") {
@@ -136,7 +134,7 @@ const formatValidators = {
136134
if (isValidJsonPointer.test(value)) {
137135
return undefined;
138136
}
139-
return errors.formatJsonPointerError({ value, pointer, schema });
137+
return draft.errors.formatJsonPointerError({ value, pointer, schema });
140138
},
141139
"relative-json-pointer": (draft, schema, value, pointer) => {
142140
if (typeof value !== "string" || value === "") {
@@ -145,7 +143,7 @@ const formatValidators = {
145143
if (isValidRelativeJsonPointer.test(value)) {
146144
return undefined;
147145
}
148-
return errors.formatJsonPointerError({ value, pointer, schema });
146+
return draft.errors.formatJsonPointerError({ value, pointer, schema });
149147
},
150148
regex: (draft, schema, value, pointer) => {
151149
if (typeof value === "string" && /\\Z$/.test(value) === false) {
@@ -154,13 +152,13 @@ const formatValidators = {
154152
return undefined;
155153
}
156154
catch (e) { } // eslint-disable-line no-empty
157-
return errors.formatRegExError({ value, pointer, schema });
155+
return draft.errors.formatRegExError({ value, pointer, schema });
158156
}
159157
// v7 tests, ignore non-regex values
160158
if (typeof value === "object" || typeof value === "number" || Array.isArray(value)) {
161159
return undefined;
162160
}
163-
return errors.formatRegExError({ value, pointer, schema });
161+
return draft.errors.formatRegExError({ value, pointer, schema });
164162
},
165163
// hh:mm:ss.sTZD
166164
// https://opis.io/json-schema/2.x/formats.html
@@ -171,7 +169,7 @@ const formatValidators = {
171169
}
172170
// https://github.com/cfworker/cfworker/blob/main/packages/json-schema/src/format.ts
173171
const matches = value.match(matchTime);
174-
return matches ? undefined : errors.formatDateTimeError({ value, pointer, schema });
172+
return matches ? undefined : draft.errors.formatDateTimeError({ value, pointer, schema });
175173
// if (!matches) {
176174
// return errors.formatDateTimeError({ value, pointer, schema });
177175
// }
@@ -195,7 +193,7 @@ const formatValidators = {
195193
if (validUrl.isUri(value)) {
196194
return undefined;
197195
}
198-
return errors.formatURIError({ value, pointer, schema });
196+
return draft.errors.formatURIError({ value, pointer, schema });
199197
},
200198
"uri-reference": (draft, schema, value, pointer) => {
201199
if (typeof value !== "string" || value === "") {
@@ -204,7 +202,7 @@ const formatValidators = {
204202
if (isValidURIRef.test(value)) {
205203
return undefined;
206204
}
207-
return errors.formatURIReferenceError({ value, pointer, schema });
205+
return draft.errors.formatURIReferenceError({ value, pointer, schema });
208206
},
209207
"uri-template": (draft, schema, value, pointer) => {
210208
if (typeof value !== "string" || value === "") {
@@ -213,13 +211,13 @@ const formatValidators = {
213211
if (isValidURITemplate.test(value)) {
214212
return undefined;
215213
}
216-
return errors.formatURITemplateError({ value, pointer, schema });
214+
return draft.errors.formatURITemplateError({ value, pointer, schema });
217215
},
218216
url: (draft, schema, value, pointer) => {
219217
if (value === "" || validUrl.isWebUri(value)) {
220218
return undefined;
221219
}
222-
return errors.formatURLError({ value, pointer, schema });
220+
return draft.errors.formatURLError({ value, pointer, schema });
223221
}
224222
};
225223
export default formatValidators;

0 commit comments

Comments
 (0)