@expo/schema-utils 0.1.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/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/build/JSONSchema.d.ts +79 -0
- package/build/JSONSchema.js +2 -0
- package/build/JSONSchema.js.map +1 -0
- package/build/deref.d.ts +9 -0
- package/build/deref.js +176 -0
- package/build/deref.js.map +1 -0
- package/build/index.d.ts +10 -0
- package/build/index.js +93 -0
- package/build/index.js.map +1 -0
- package/build/validate.d.ts +11 -0
- package/build/validate.js +565 -0
- package/build/validate.js.map +1 -0
- package/package.json +37 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present 650 Industries, Inc. (aka Expo)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This interface was referenced by `JSONSchema`'s JSON-Schema
|
|
3
|
+
* via the `definition` "positiveInteger".
|
|
4
|
+
*/
|
|
5
|
+
export type PositiveInteger = number;
|
|
6
|
+
/**
|
|
7
|
+
* This interface was referenced by `JSONSchema`'s JSON-Schema
|
|
8
|
+
* via the `definition` "positiveIntegerDefault0".
|
|
9
|
+
*/
|
|
10
|
+
export type PositiveIntegerDefault0 = PositiveInteger;
|
|
11
|
+
/**
|
|
12
|
+
* @minItems 1
|
|
13
|
+
*
|
|
14
|
+
* This interface was referenced by `JSONSchema`'s JSON-Schema
|
|
15
|
+
* via the `definition` "schemaArray".
|
|
16
|
+
*/
|
|
17
|
+
export type SchemaArray = [JSONSchema, ...JSONSchema[]];
|
|
18
|
+
/**
|
|
19
|
+
* @minItems 1
|
|
20
|
+
*
|
|
21
|
+
* This interface was referenced by `JSONSchema`'s JSON-Schema
|
|
22
|
+
* via the `definition` "stringArray".
|
|
23
|
+
*/
|
|
24
|
+
export type StringArray = [string, ...string[]];
|
|
25
|
+
/**
|
|
26
|
+
* This interface was referenced by `JSONSchema`'s JSON-Schema
|
|
27
|
+
* via the `definition` "simpleTypes".
|
|
28
|
+
*/
|
|
29
|
+
export type SimpleTypes = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
|
|
30
|
+
/**
|
|
31
|
+
* Core schema meta-schema
|
|
32
|
+
*/
|
|
33
|
+
export interface JSONSchema {
|
|
34
|
+
id?: string;
|
|
35
|
+
$schema?: string;
|
|
36
|
+
title?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
default?: unknown;
|
|
39
|
+
multipleOf?: number;
|
|
40
|
+
maximum?: number;
|
|
41
|
+
exclusiveMaximum?: boolean;
|
|
42
|
+
minimum?: number;
|
|
43
|
+
exclusiveMinimum?: boolean;
|
|
44
|
+
maxLength?: PositiveInteger;
|
|
45
|
+
minLength?: PositiveIntegerDefault0;
|
|
46
|
+
pattern?: string;
|
|
47
|
+
additionalItems?: boolean | JSONSchema;
|
|
48
|
+
items?: JSONSchema | SchemaArray;
|
|
49
|
+
maxItems?: PositiveInteger;
|
|
50
|
+
minItems?: PositiveIntegerDefault0;
|
|
51
|
+
uniqueItems?: boolean;
|
|
52
|
+
maxProperties?: PositiveInteger;
|
|
53
|
+
minProperties?: PositiveIntegerDefault0;
|
|
54
|
+
required?: StringArray;
|
|
55
|
+
additionalProperties?: boolean | JSONSchema;
|
|
56
|
+
definitions?: {
|
|
57
|
+
[k: string]: JSONSchema;
|
|
58
|
+
};
|
|
59
|
+
properties?: {
|
|
60
|
+
[k: string]: JSONSchema;
|
|
61
|
+
};
|
|
62
|
+
patternProperties?: {
|
|
63
|
+
[k: string]: JSONSchema;
|
|
64
|
+
};
|
|
65
|
+
dependencies?: {
|
|
66
|
+
[k: string]: (JSONSchema | StringArray) | undefined;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* @minItems 1
|
|
70
|
+
*/
|
|
71
|
+
enum?: [unknown, ...unknown[]];
|
|
72
|
+
type?: SimpleTypes | [SimpleTypes, ...SimpleTypes[]];
|
|
73
|
+
format?: string;
|
|
74
|
+
allOf?: SchemaArray;
|
|
75
|
+
anyOf?: SchemaArray;
|
|
76
|
+
oneOf?: SchemaArray;
|
|
77
|
+
not?: JSONSchema;
|
|
78
|
+
[k: string]: unknown | undefined;
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONSchema.js","names":[],"sources":["../src/JSONSchema.ts"],"sourcesContent":["/* eslint:disable */\n\n/**\n * This interface was referenced by `JSONSchema`'s JSON-Schema\n * via the `definition` \"positiveInteger\".\n */\nexport type PositiveInteger = number;\n/**\n * This interface was referenced by `JSONSchema`'s JSON-Schema\n * via the `definition` \"positiveIntegerDefault0\".\n */\nexport type PositiveIntegerDefault0 = PositiveInteger;\n/**\n * @minItems 1\n *\n * This interface was referenced by `JSONSchema`'s JSON-Schema\n * via the `definition` \"schemaArray\".\n */\nexport type SchemaArray = [JSONSchema, ...JSONSchema[]];\n/**\n * @minItems 1\n *\n * This interface was referenced by `JSONSchema`'s JSON-Schema\n * via the `definition` \"stringArray\".\n */\nexport type StringArray = [string, ...string[]];\n/**\n * This interface was referenced by `JSONSchema`'s JSON-Schema\n * via the `definition` \"simpleTypes\".\n */\nexport type SimpleTypes = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';\n\n/**\n * Core schema meta-schema\n */\nexport interface JSONSchema {\n id?: string;\n $schema?: string;\n title?: string;\n description?: string;\n default?: unknown;\n multipleOf?: number;\n maximum?: number;\n exclusiveMaximum?: boolean;\n minimum?: number;\n exclusiveMinimum?: boolean;\n maxLength?: PositiveInteger;\n minLength?: PositiveIntegerDefault0;\n pattern?: string;\n additionalItems?: boolean | JSONSchema;\n items?: JSONSchema | SchemaArray;\n maxItems?: PositiveInteger;\n minItems?: PositiveIntegerDefault0;\n uniqueItems?: boolean;\n maxProperties?: PositiveInteger;\n minProperties?: PositiveIntegerDefault0;\n required?: StringArray;\n additionalProperties?: boolean | JSONSchema;\n definitions?: {\n [k: string]: JSONSchema;\n };\n properties?: {\n [k: string]: JSONSchema;\n };\n patternProperties?: {\n [k: string]: JSONSchema;\n };\n dependencies?: {\n [k: string]: (JSONSchema | StringArray) | undefined;\n };\n /**\n * @minItems 1\n */\n enum?: [unknown, ...unknown[]];\n type?: SimpleTypes | [SimpleTypes, ...SimpleTypes[]];\n format?: string;\n allOf?: SchemaArray;\n anyOf?: SchemaArray;\n oneOf?: SchemaArray;\n not?: JSONSchema;\n [k: string]: unknown | undefined;\n}\n"],"mappings":"","ignoreList":[]}
|
package/build/deref.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Dereference JSON schema pointers.
|
|
2
|
+
*
|
|
3
|
+
* @remarks
|
|
4
|
+
* This is a minimal reimplementation of `json-schema-deref-sync` without
|
|
5
|
+
* file reference, URL/web reference, and loader support.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/cvent/json-schema-deref-sync
|
|
8
|
+
*/
|
|
9
|
+
export declare function deref(input: any): any;
|
package/build/deref.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deref = deref;
|
|
7
|
+
/** Return JSON schema ref if input is of `NodeRef` type */
|
|
8
|
+
const getRef = node => node != null && typeof node === 'object' && '$ref' in node && typeof node.$ref === 'string' ? node.$ref : undefined;
|
|
9
|
+
|
|
10
|
+
/** Parse a JSON schema ref into a path array, or return undefined */
|
|
11
|
+
const parseRefMaybe = ref => {
|
|
12
|
+
if (ref == null || ref[0] !== '#') {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const props = [];
|
|
16
|
+
let startIndex = 1;
|
|
17
|
+
let index = 1;
|
|
18
|
+
let char;
|
|
19
|
+
while (index < ref.length) {
|
|
20
|
+
while ((char = ref.charCodeAt(index++)) && char !== 47 /*'/'*/);
|
|
21
|
+
const prop = ref.slice(startIndex, index - 1);
|
|
22
|
+
startIndex = index;
|
|
23
|
+
if (prop) props.push(prop);
|
|
24
|
+
}
|
|
25
|
+
return props.length ? props : undefined;
|
|
26
|
+
};
|
|
27
|
+
const NOT_FOUND_SYMBOL = Symbol();
|
|
28
|
+
|
|
29
|
+
/** Get value at given JSON schema path or return `NOT_FOUND_SYMBOL` */
|
|
30
|
+
const getValueAtPath = (input, ref) => {
|
|
31
|
+
let node = input;
|
|
32
|
+
for (let index = 0; index < ref.length; index++) {
|
|
33
|
+
const part = ref[index];
|
|
34
|
+
if (node != null && typeof node === 'object' && part in node) {
|
|
35
|
+
node = node[part];
|
|
36
|
+
} else {
|
|
37
|
+
node = NOT_FOUND_SYMBOL;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return node;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Find all JSON schema refs recursively and add them to `refs` Map */
|
|
45
|
+
const findRefsRec = (node, refs, path) => {
|
|
46
|
+
if (node == null || typeof node !== 'object') {} else if (Array.isArray(node)) {
|
|
47
|
+
for (let index = 0, l = node.length; index < l; index++) {
|
|
48
|
+
const value = node[index];
|
|
49
|
+
const ref = getRef(value);
|
|
50
|
+
if (ref) {
|
|
51
|
+
const targetRef = parseRefMaybe(ref);
|
|
52
|
+
if (targetRef) refs.set([...path, index], targetRef);
|
|
53
|
+
} else if (value != null && typeof value === 'object') {
|
|
54
|
+
path.push(index);
|
|
55
|
+
findRefsRec(value, refs, path);
|
|
56
|
+
path.pop();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
const record = node;
|
|
61
|
+
for (const key in record) {
|
|
62
|
+
const value = record[key];
|
|
63
|
+
const ref = getRef(value);
|
|
64
|
+
if (ref) {
|
|
65
|
+
const targetRef = parseRefMaybe(ref);
|
|
66
|
+
if (targetRef) refs.set([...path, key], targetRef);
|
|
67
|
+
} else if (value != null && typeof value === 'object') {
|
|
68
|
+
path.push(key);
|
|
69
|
+
findRefsRec(value, refs, path);
|
|
70
|
+
path.pop();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** Detect whether target (where we set the source value) is a nested path inside the source path */
|
|
77
|
+
const isSelfReferencingRefEntry = (target, source) => {
|
|
78
|
+
for (let index = 0; index < source.length; index++) {
|
|
79
|
+
if (source[index] !== target[index]) return false;
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** Return sorted refs entries. Longest target paths will be returned first */
|
|
85
|
+
const getSortedRefEntries = refs => {
|
|
86
|
+
const entries = [...refs.entries()].sort((a, b) => b[1].length - a[1].length);
|
|
87
|
+
// Filter out self-referenceing paths. If we set nested targets to source values, we'd
|
|
88
|
+
// create unserializable circular references
|
|
89
|
+
return entries.filter(entry => !isSelfReferencingRefEntry(entry[0], entry[1]));
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** Dereference JSON schema pointers.
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
* This is a minimal reimplementation of `json-schema-deref-sync` without
|
|
96
|
+
* file reference, URL/web reference, and loader support.
|
|
97
|
+
*
|
|
98
|
+
* @see https://github.com/cvent/json-schema-deref-sync
|
|
99
|
+
*/
|
|
100
|
+
function deref(input) {
|
|
101
|
+
const refs = new Map();
|
|
102
|
+
// Find all JSON schema refs paths
|
|
103
|
+
findRefsRec(input, refs, []);
|
|
104
|
+
// Shallow copy output
|
|
105
|
+
const output = {
|
|
106
|
+
...input
|
|
107
|
+
};
|
|
108
|
+
// Process all ref entries with deepest targets first
|
|
109
|
+
nextRef: for (const [target, source] of getSortedRefEntries(refs)) {
|
|
110
|
+
let inputNode = input;
|
|
111
|
+
let outputNode = output;
|
|
112
|
+
let targetIndex = 0;
|
|
113
|
+
// For each path part on the target, traverse the output and clone the input
|
|
114
|
+
// to not pollute it
|
|
115
|
+
for (; targetIndex < target.length - 1; targetIndex++) {
|
|
116
|
+
const part = target[targetIndex];
|
|
117
|
+
if (inputNode == null || typeof inputNode !== 'object' || !(part in inputNode)) {
|
|
118
|
+
// If the part doesn't exist, we abort
|
|
119
|
+
break;
|
|
120
|
+
} else if (outputNode[part] === inputNode[part]) {
|
|
121
|
+
// Copy the input on the output if references are equal
|
|
122
|
+
outputNode[part] = Array.isArray(inputNode[part]) ? [...inputNode[part]] : {
|
|
123
|
+
...inputNode[part]
|
|
124
|
+
};
|
|
125
|
+
inputNode = inputNode[part];
|
|
126
|
+
outputNode = outputNode[part];
|
|
127
|
+
} else {
|
|
128
|
+
// If this part has already been copied, abort
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// For each remaining part on the target, continue traversing the output
|
|
133
|
+
for (; targetIndex < target.length - 1; targetIndex++) {
|
|
134
|
+
const part = target[targetIndex];
|
|
135
|
+
if (outputNode == null || typeof outputNode !== 'object' || !(part in outputNode)) {
|
|
136
|
+
// If the part doesn't exist, skip the entire ref
|
|
137
|
+
continue nextRef;
|
|
138
|
+
} else {
|
|
139
|
+
outputNode = outputNode[part];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Get value from output
|
|
143
|
+
let sourceValue = getValueAtPath(output, source);
|
|
144
|
+
if (sourceValue === NOT_FOUND_SYMBOL) {
|
|
145
|
+
// If no value was found, try to get a value from the input instead
|
|
146
|
+
sourceValue = getValueAtPath(input, source);
|
|
147
|
+
// Otherwise, skip this ref
|
|
148
|
+
if (sourceValue === NOT_FOUND_SYMBOL) continue;
|
|
149
|
+
}
|
|
150
|
+
// Set the source value on the target path
|
|
151
|
+
// The for-loops prior have made sure that the output has already been deeply
|
|
152
|
+
// cloned and traversed for the entire path
|
|
153
|
+
outputNode[target[target.length - 1]] = sourceValue;
|
|
154
|
+
}
|
|
155
|
+
// Handle root refs last
|
|
156
|
+
const rootTargetRef = parseRefMaybe(getRef(input));
|
|
157
|
+
if (rootTargetRef) {
|
|
158
|
+
// Get value from output
|
|
159
|
+
let sourceValue = getValueAtPath(output, rootTargetRef);
|
|
160
|
+
// If no value was found, try to get a value from the input instead
|
|
161
|
+
if (sourceValue === NOT_FOUND_SYMBOL) {
|
|
162
|
+
sourceValue = getValueAtPath(input, rootTargetRef);
|
|
163
|
+
}
|
|
164
|
+
// Assign the target object to the output
|
|
165
|
+
if (sourceValue !== NOT_FOUND_SYMBOL && sourceValue != null) {
|
|
166
|
+
return typeof sourceValue === 'object' ? {
|
|
167
|
+
...sourceValue,
|
|
168
|
+
title: output.title,
|
|
169
|
+
description: output.description
|
|
170
|
+
} : sourceValue;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Return the output with resolved refs
|
|
174
|
+
return output;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=deref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deref.js","names":["getRef","node","$ref","undefined","parseRefMaybe","ref","props","startIndex","index","char","length","charCodeAt","prop","slice","push","NOT_FOUND_SYMBOL","Symbol","getValueAtPath","input","part","findRefsRec","refs","path","Array","isArray","l","value","targetRef","set","pop","record","key","isSelfReferencingRefEntry","target","source","getSortedRefEntries","entries","sort","a","b","filter","entry","deref","Map","output","nextRef","inputNode","outputNode","targetIndex","sourceValue","rootTargetRef","title","description"],"sources":["../src/deref.ts"],"sourcesContent":["type RefPath = readonly (string | number)[];\n\ninterface NodeRef {\n $ref: string;\n}\n\n/** Return JSON schema ref if input is of `NodeRef` type */\nconst getRef = (node: NodeRef | unknown): string | undefined =>\n node != null && typeof node === 'object' && '$ref' in node && typeof node.$ref === 'string'\n ? node.$ref\n : undefined;\n\n/** Parse a JSON schema ref into a path array, or return undefined */\nconst parseRefMaybe = (ref: string | undefined): RefPath | undefined => {\n if (ref == null || ref[0] !== '#') {\n return undefined;\n }\n const props = [];\n let startIndex = 1;\n let index = 1;\n let char: number;\n while (index < ref.length) {\n while ((char = ref.charCodeAt(index++)) && char !== 47 /*'/'*/);\n const prop = ref.slice(startIndex, index - 1);\n startIndex = index;\n if (prop) props.push(prop);\n }\n return props.length ? props : undefined;\n};\n\nconst NOT_FOUND_SYMBOL = Symbol();\n\n/** Get value at given JSON schema path or return `NOT_FOUND_SYMBOL` */\nconst getValueAtPath = (input: unknown, ref: RefPath): unknown | typeof NOT_FOUND_SYMBOL => {\n let node = input;\n for (let index = 0; index < ref.length; index++) {\n const part = ref[index];\n if (node != null && typeof node === 'object' && part in node) {\n node = (node as Record<string, unknown>)[part];\n } else {\n node = NOT_FOUND_SYMBOL;\n break;\n }\n }\n return node;\n};\n\n/** Find all JSON schema refs recursively and add them to `refs` Map */\nconst findRefsRec = (\n node: unknown,\n refs: Map<RefPath, RefPath>,\n path: (string | number)[]\n): void => {\n if (node == null || typeof node !== 'object') {\n } else if (Array.isArray(node)) {\n for (let index = 0, l = node.length; index < l; index++) {\n const value = node[index];\n const ref = getRef(value);\n if (ref) {\n const targetRef = parseRefMaybe(ref);\n if (targetRef) refs.set([...path, index], targetRef);\n } else if (value != null && typeof value === 'object') {\n path.push(index);\n findRefsRec(value, refs, path);\n path.pop();\n }\n }\n } else {\n const record = node as Record<string, unknown>;\n for (const key in record) {\n const value = record[key];\n const ref = getRef(value);\n if (ref) {\n const targetRef = parseRefMaybe(ref);\n if (targetRef) refs.set([...path, key], targetRef);\n } else if (value != null && typeof value === 'object') {\n path.push(key);\n findRefsRec(value, refs, path);\n path.pop();\n }\n }\n }\n};\n\n/** Detect whether target (where we set the source value) is a nested path inside the source path */\nconst isSelfReferencingRefEntry = (target: RefPath, source: RefPath) => {\n for (let index = 0; index < source.length; index++) {\n if (source[index] !== target[index]) return false;\n }\n return true;\n};\n\n/** Return sorted refs entries. Longest target paths will be returned first */\nconst getSortedRefEntries = (refs: Map<RefPath, RefPath>): readonly [RefPath, RefPath][] => {\n const entries = [...refs.entries()].sort((a, b) => b[1].length - a[1].length);\n // Filter out self-referenceing paths. If we set nested targets to source values, we'd\n // create unserializable circular references\n return entries.filter((entry) => !isSelfReferencingRefEntry(entry[0], entry[1]));\n};\n\n/** Dereference JSON schema pointers.\n *\n * @remarks\n * This is a minimal reimplementation of `json-schema-deref-sync` without\n * file reference, URL/web reference, and loader support.\n *\n * @see https://github.com/cvent/json-schema-deref-sync\n */\nexport function deref(input: any): any {\n const refs = new Map<RefPath, RefPath>();\n // Find all JSON schema refs paths\n findRefsRec(input, refs, []);\n // Shallow copy output\n const output = { ...input };\n // Process all ref entries with deepest targets first\n nextRef: for (const [target, source] of getSortedRefEntries(refs)) {\n let inputNode = input;\n let outputNode = output;\n let targetIndex = 0;\n // For each path part on the target, traverse the output and clone the input\n // to not pollute it\n for (; targetIndex < target.length - 1; targetIndex++) {\n const part = target[targetIndex];\n if (inputNode == null || typeof inputNode !== 'object' || !(part in inputNode)) {\n // If the part doesn't exist, we abort\n break;\n } else if (outputNode[part] === inputNode[part]) {\n // Copy the input on the output if references are equal\n outputNode[part] = Array.isArray(inputNode[part])\n ? [...inputNode[part]]\n : { ...inputNode[part] };\n inputNode = inputNode[part];\n outputNode = outputNode[part];\n } else {\n // If this part has already been copied, abort\n break;\n }\n }\n // For each remaining part on the target, continue traversing the output\n for (; targetIndex < target.length - 1; targetIndex++) {\n const part = target[targetIndex];\n if (outputNode == null || typeof outputNode !== 'object' || !(part in outputNode)) {\n // If the part doesn't exist, skip the entire ref\n continue nextRef;\n } else {\n outputNode = outputNode[part];\n }\n }\n // Get value from output\n let sourceValue = getValueAtPath(output, source);\n if (sourceValue === NOT_FOUND_SYMBOL) {\n // If no value was found, try to get a value from the input instead\n sourceValue = getValueAtPath(input, source);\n // Otherwise, skip this ref\n if (sourceValue === NOT_FOUND_SYMBOL) continue;\n }\n // Set the source value on the target path\n // The for-loops prior have made sure that the output has already been deeply\n // cloned and traversed for the entire path\n outputNode[target[target.length - 1]] = sourceValue;\n }\n // Handle root refs last\n const rootTargetRef = parseRefMaybe(getRef(input));\n if (rootTargetRef) {\n // Get value from output\n let sourceValue = getValueAtPath(output, rootTargetRef);\n // If no value was found, try to get a value from the input instead\n if (sourceValue === NOT_FOUND_SYMBOL) {\n sourceValue = getValueAtPath(input, rootTargetRef);\n }\n // Assign the target object to the output\n if (sourceValue !== NOT_FOUND_SYMBOL && sourceValue != null) {\n return typeof sourceValue === 'object'\n ? {\n ...sourceValue,\n title: output.title,\n description: output.description,\n }\n : sourceValue;\n }\n }\n // Return the output with resolved refs\n return output;\n}\n"],"mappings":";;;;;;AAMA;AACA,MAAMA,MAAM,GAAIC,IAAuB,IACrCA,IA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,CAAC;MAChC,IAAID,UAAU,IAAI,IAAI,IAAI,OAAOA,UAAU,KAAK,QAAQ,IAAI,EAAE5B,IAAI,IAAI4B,UAAU,CAAC,EAAE;QACjF;QACA,SAASF,OAAO;MAClB,CAAC,MAAM;QACLE,UAAU,GAAGA,UAAU,CAAC5B,IAAI,CAAC;MAC/B;IACF;IACA;IACA,IAAI8B,WAAW,GAAGhC,cAAc,CAAC2B,MAAM,EAAEV,MAAM,CAAC;IAChD,IAAIe,WAAW,KAAKlC,gBAAgB,EAAE;MACpC;MACAkC,WAAW,GAAGhC,cAAc,CAACC,KAAK,EAAEgB,MAAM,CAAC;MAC3C;MACA,IAAIe,WAAW,KAAKlC,gBAAgB,EAAE;IACxC;IACA;IACA;IACA;IACAgC,UAAU,CAACd,MAAM,CAACA,MAAM,CAACvB,MAAM,GAAG,CAAC,CAAC,CAAC,GAAGuC,WAAW;EACrD;EACA;EACA,MAAMC,aAAa,GAAG9C,aAAa,CAACJ,MAAM,CAACkB,KAAK,CAAC,CAAC;EAClD,IAAIgC,aAAa,EAAE;IACjB;IACA,IAAID,WAAW,GAAGhC,cAAc,CAAC2B,MAAM,EAAEM,aAAa,CAAC;IACvD;IACA,IAAID,WAAW,KAAKlC,gBAAgB,EAAE;MACpCkC,WAAW,GAAGhC,cAAc,CAACC,KAAK,EAAEgC,aAAa,CAAC;IACpD;IACA;IACA,IAAID,WAAW,KAAKlC,gBAAgB,IAAIkC,WAAW,IAAI,IAAI,EAAE;MAC3D,OAAO,OAAOA,WAAW,KAAK,QAAQ,GAClC;QACE,GAAGA,WAAW;QACdE,KAAK,EAAEP,MAAM,CAACO,KAAK;QACnBC,WAAW,EAAER,MAAM,CAACQ;MACtB,CAAC,GACDH,WAAW;IACjB;EACF;EACA;EACA,OAAOL,MAAM;AACf","ignoreList":[]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSONSchema } from './JSONSchema';
|
|
2
|
+
import { BaseValidationError, ValidationError as ValidationResult } from './validate';
|
|
3
|
+
export { JSONSchema } from './JSONSchema';
|
|
4
|
+
export declare class ValidationError extends Error {
|
|
5
|
+
schema: JSONSchema;
|
|
6
|
+
errors: BaseValidationError[];
|
|
7
|
+
constructor(result: ValidationResult, schema: JSONSchema);
|
|
8
|
+
}
|
|
9
|
+
export declare function derefSchema(schema: JSONSchema): JSONSchema;
|
|
10
|
+
export declare function validate(schema: JSONSchema, value: unknown): void;
|
package/build/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "JSONSchema", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _JSONSchema().JSONSchema;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.ValidationError = void 0;
|
|
13
|
+
exports.derefSchema = derefSchema;
|
|
14
|
+
exports.validate = validate;
|
|
15
|
+
function _deref() {
|
|
16
|
+
const data = require("./deref");
|
|
17
|
+
_deref = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _validate() {
|
|
23
|
+
const data = require("./validate");
|
|
24
|
+
_validate = function () {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
function _JSONSchema() {
|
|
30
|
+
const data = require("./JSONSchema");
|
|
31
|
+
_JSONSchema = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
const CACHE_SYMBOL = Symbol('@expo/schema-utils');
|
|
37
|
+
const flattenValidationResults = (input, output = []) => {
|
|
38
|
+
output.push({
|
|
39
|
+
message: input.message,
|
|
40
|
+
path: input.path,
|
|
41
|
+
keyword: input.keyword,
|
|
42
|
+
value: input.value
|
|
43
|
+
});
|
|
44
|
+
for (let idx = 0; input.cause && idx < input.cause.length; idx++) {
|
|
45
|
+
flattenValidationResults(input.cause[idx], output);
|
|
46
|
+
}
|
|
47
|
+
return output;
|
|
48
|
+
};
|
|
49
|
+
const toErrorMessage = (errors, name) => {
|
|
50
|
+
let message = `Invalid options object. ${name} has been initialized using an options object that does not match the API schema.`;
|
|
51
|
+
for (const error of errors) {
|
|
52
|
+
message += `\n - options${error.path} (${error.keyword}): ${error.message}`;
|
|
53
|
+
}
|
|
54
|
+
return message;
|
|
55
|
+
};
|
|
56
|
+
class ValidationError extends Error {
|
|
57
|
+
constructor(result, schema) {
|
|
58
|
+
const errors = flattenValidationResults(result);
|
|
59
|
+
super(toErrorMessage(errors, typeof schema.title === 'string' ? schema.title : 'Value'));
|
|
60
|
+
this.name = 'ValidationError';
|
|
61
|
+
this.errors = errors;
|
|
62
|
+
this.schema = schema;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.ValidationError = ValidationError;
|
|
66
|
+
const derefSchemaCache = schema => {
|
|
67
|
+
let derefed = schema[CACHE_SYMBOL];
|
|
68
|
+
if (!derefed) {
|
|
69
|
+
derefed = {
|
|
70
|
+
schema: (0, _deref().deref)(schema),
|
|
71
|
+
cache: new WeakMap()
|
|
72
|
+
};
|
|
73
|
+
schema[CACHE_SYMBOL] = derefed;
|
|
74
|
+
}
|
|
75
|
+
return derefed;
|
|
76
|
+
};
|
|
77
|
+
function derefSchema(schema) {
|
|
78
|
+
return derefSchemaCache(schema).schema;
|
|
79
|
+
}
|
|
80
|
+
function validate(schema, value) {
|
|
81
|
+
const data = derefSchemaCache(schema);
|
|
82
|
+
let result;
|
|
83
|
+
if (typeof value !== 'object' || value == null || (result = data.cache.get(value)) === undefined) {
|
|
84
|
+
result = (0, _validate().validateSchema)(data.schema, value, '');
|
|
85
|
+
if (typeof value === 'object' && value != null) {
|
|
86
|
+
data.cache.set(value, result);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (result) {
|
|
90
|
+
throw new ValidationError(result, data.schema);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_deref","data","require","_validate","_JSONSchema","CACHE_SYMBOL","Symbol","flattenValidationResults","input","output","push","message","path","keyword","value","idx","cause","length","toErrorMessage","errors","name","error","ValidationError","Error","constructor","result","schema","title","exports","derefSchemaCache","derefed","deref","cache","WeakMap","derefSchema","validate","get","undefined","validateSchema","set"],"sources":["../src/index.ts"],"sourcesContent":["import { JSONSchema } from './JSONSchema';\nimport { deref } from './deref';\nimport {\n validateSchema,\n BaseValidationError,\n ValidationError as ValidationResult,\n} from './validate';\n\nexport { JSONSchema } from './JSONSchema';\n\nconst CACHE_SYMBOL = Symbol('@expo/schema-utils');\n\ninterface SchemaCacheData {\n schema: JSONSchema;\n cache: WeakMap<object, ValidationResult | null>;\n}\n\nconst flattenValidationResults = (\n input: ValidationResult,\n output: BaseValidationError[] = []\n): BaseValidationError[] => {\n output.push({\n message: input.message,\n path: input.path,\n keyword: input.keyword,\n value: input.value,\n });\n for (let idx = 0; input.cause && idx < input.cause.length; idx++) {\n flattenValidationResults(input.cause[idx], output);\n }\n return output;\n};\n\nconst toErrorMessage = (errors: BaseValidationError[], name: string) => {\n let message = `Invalid options object. ${name} has been initialized using an options object that does not match the API schema.`;\n for (const error of errors) {\n message += `\\n - options${error.path} (${error.keyword}): ${error.message}`;\n }\n return message;\n};\n\nexport class ValidationError extends Error {\n schema: JSONSchema;\n errors: BaseValidationError[];\n constructor(result: ValidationResult, schema: JSONSchema) {\n const errors = flattenValidationResults(result);\n super(toErrorMessage(errors, typeof schema.title === 'string' ? schema.title : 'Value'));\n this.name = 'ValidationError';\n this.errors = errors;\n this.schema = schema;\n }\n}\n\nconst derefSchemaCache = (schema: JSONSchema): SchemaCacheData => {\n let derefed = (schema as any)[CACHE_SYMBOL] as SchemaCacheData | undefined;\n if (!derefed) {\n derefed = {\n schema: deref(schema),\n cache: new WeakMap(),\n };\n (schema as any)[CACHE_SYMBOL] = derefed;\n }\n return derefed!;\n};\n\nexport function derefSchema(schema: JSONSchema): JSONSchema {\n return derefSchemaCache(schema).schema;\n}\n\nexport function validate(schema: JSONSchema, value: unknown) {\n const data = derefSchemaCache(schema);\n let result: ValidationResult | null | undefined;\n if (\n typeof value !== 'object' ||\n value == null ||\n (result = data.cache.get(value)) === undefined\n ) {\n result = validateSchema(data.schema, value, '');\n if (typeof value === 'object' && value != null) {\n data.cache.set(value, result);\n }\n }\n if (result) {\n throw new ValidationError(result, data.schema);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,MAAMI,YAAY,GAAGC,MAAM,CAAC,oBAAoB,CAAC;AAOjD,MAAMC,wBAAwB,GAAGA,CAC/BC,KAAuB,EACvBC,MAA6B,GAAG,EAAE,KACR;EAC1BA,MAAM,CAACC,IAAI,CAAC;IACVC,OAAO,EAAEH,KAAK,CAACG,OAAO;IACtBC,IAAI,EAAEJ,KAAK,CAACI,IAAI;IAChBC,OAAO,EAAEL,KAAK,CAACK,OAAO;IACtBC,KAAK,EAAEN,KAAK,CAACM;EACf,CAAC,CAAC;EACF,KAAK,IAAIC,GAAG,GAAG,CAAC,EAAEP,KAAK,CAACQ,KAAK,IAAID,GAA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AC;AAEM,SAASI,WAAWA,CAACR,MAAkB,EAAc;EAC1D,OAAOG,gBAAgB,CAACH,MAAM,CAAC,CAACA,MAAM;AACxC;AAEO,SAASS,QAAQA,CAACT,MAAkB,EAAEZ,KAAc,EAAE;EAC3D,MAAMb,IAAI,GAAG4B,gBAAgB,CAACH,MAAM,CAAC;EACrC,IAAID,MAA2C;EAC/C,IACE,OAAOX,KAAK,KAAK,QAAQ,IACzBA,KAAK,IAAI,IAAI,IACb,CAACW,MAAM,GAAGxB,IAAI,CAAC+B,KAAK,CAACI,GAAG,CAACtB,KAAK,CAAC,MAAMuB,SAAS,EAC9C;IACAZ,MAAM,GAAG,IAAAa,0BAAc,EAACrC,IAAI,CAACyB,MAAM,EAAEZ,KAAK,EAAE,EAAE,CAAC;IAC/C,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,IAAI,IAAI,EAAE;MAC9Cb,IAAI,CAAC+B,KAAK,CAACO,GAAG,CAACzB,KAAK,EAAEW,MAAM,CAAC;IAC/B;EACF;EACA,IAAIA,MAAM,EAAE;IACV,MAAM,IAAIH,eAAe,CAACG,MAAM,EAAExB,IAAI,CAACyB,MAAM,CAAC;EAChD;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JSONSchema } from './JSONSchema';
|
|
2
|
+
export interface BaseValidationError {
|
|
3
|
+
message: string;
|
|
4
|
+
path: string;
|
|
5
|
+
keyword: string;
|
|
6
|
+
value: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface ValidationError extends BaseValidationError {
|
|
9
|
+
cause?: ValidationError[];
|
|
10
|
+
}
|
|
11
|
+
export declare const validateSchema: (schema: JSONSchema, value: unknown, path: string) => ValidationError | null;
|
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateSchema = void 0;
|
|
7
|
+
const getValueType = value => {
|
|
8
|
+
const typeOf = typeof value;
|
|
9
|
+
switch (typeOf) {
|
|
10
|
+
case 'number':
|
|
11
|
+
return Number.isInteger(value) ? 'integer' : 'number';
|
|
12
|
+
case 'boolean':
|
|
13
|
+
case 'string':
|
|
14
|
+
return typeOf;
|
|
15
|
+
case 'object':
|
|
16
|
+
if (value === null) {
|
|
17
|
+
return 'null';
|
|
18
|
+
} else if (Array.isArray(value)) {
|
|
19
|
+
return 'array';
|
|
20
|
+
} else {
|
|
21
|
+
return 'object';
|
|
22
|
+
}
|
|
23
|
+
default:
|
|
24
|
+
return typeOf;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const isDeepEqual = (a, b) => {
|
|
28
|
+
if (a === b) {
|
|
29
|
+
return true;
|
|
30
|
+
} else if (a === null || b === null) {
|
|
31
|
+
return false;
|
|
32
|
+
} else if (typeof a !== typeof b) {
|
|
33
|
+
return false;
|
|
34
|
+
} else if (Array.isArray(a)) {
|
|
35
|
+
if (!Array.isArray(b) || a.length !== b.length) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
for (let idx = 0; idx < a.length; idx++) {
|
|
39
|
+
if (!isDeepEqual(a[idx], b[idx])) return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
} else if (typeof a === 'object') {
|
|
43
|
+
const keysA = Object.keys(a);
|
|
44
|
+
const keysB = Object.keys(b);
|
|
45
|
+
if (!isDeepEqual(keysA, keysB)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
for (let idx = 0; idx < keysA.length; idx++) {
|
|
49
|
+
if (!isDeepEqual(a[keysA[idx]], b[keysA[idx]])) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
} else {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const areArrayValuesUnique = array => {
|
|
59
|
+
for (let i = 0; i < array.length; i++) {
|
|
60
|
+
for (let j = 0; j < array.length; j++) {
|
|
61
|
+
if (i !== j && isDeepEqual(array[i], array[j])) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
};
|
|
68
|
+
const dateRe = /^\d{4}-\d{2}-\d{2}$/;
|
|
69
|
+
const dateTimeRe = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/;
|
|
70
|
+
const timeRe = /^\d{2}:\d{2}:\d{2}$/;
|
|
71
|
+
const emailRe = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
72
|
+
const hostnameRe = /^[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])?)*$/;
|
|
73
|
+
const uriRe = /^https?:\/\//;
|
|
74
|
+
const validateFormat = (format, value) => {
|
|
75
|
+
// NOTE: Left out ipv4 and ipv6
|
|
76
|
+
switch (format) {
|
|
77
|
+
case 'date-time':
|
|
78
|
+
return dateTimeRe.test(value);
|
|
79
|
+
case 'date':
|
|
80
|
+
return dateRe.test(value);
|
|
81
|
+
case 'time':
|
|
82
|
+
return timeRe.test(value);
|
|
83
|
+
case 'email':
|
|
84
|
+
return emailRe.test(value);
|
|
85
|
+
case 'hostname':
|
|
86
|
+
return hostnameRe.test(value);
|
|
87
|
+
case 'uri':
|
|
88
|
+
return uriRe.test(value);
|
|
89
|
+
default:
|
|
90
|
+
throw new TypeError(`Unsupported format "${format}"`);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const isEnumValue = (enumValues, value) => {
|
|
94
|
+
if (!enumValues.length) {
|
|
95
|
+
throw new TypeError('Empty enum array');
|
|
96
|
+
}
|
|
97
|
+
for (let idx = 0; idx < enumValues.length; idx++) {
|
|
98
|
+
if (isDeepEqual(value, enumValues[idx])) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
const validateString = (schema, value, path) => {
|
|
105
|
+
if (schema.minLength != null && value.length < schema.minLength) {
|
|
106
|
+
return {
|
|
107
|
+
message: `String must be at least ${schema.minLength} characters`,
|
|
108
|
+
keyword: 'minLength',
|
|
109
|
+
path,
|
|
110
|
+
value
|
|
111
|
+
};
|
|
112
|
+
} else if (schema.maxLength != null && value.length > schema.maxLength) {
|
|
113
|
+
return {
|
|
114
|
+
message: `String must be at most ${schema.maxLength} characters`,
|
|
115
|
+
keyword: 'maxLength',
|
|
116
|
+
path,
|
|
117
|
+
value
|
|
118
|
+
};
|
|
119
|
+
} else if (schema.pattern != null && !new RegExp(schema.pattern).test(value)) {
|
|
120
|
+
return {
|
|
121
|
+
message: `String does not match pattern: ${schema.pattern}`,
|
|
122
|
+
keyword: 'pattern',
|
|
123
|
+
path,
|
|
124
|
+
value
|
|
125
|
+
};
|
|
126
|
+
} else if (schema.format != null && !validateFormat(schema.format, value)) {
|
|
127
|
+
return {
|
|
128
|
+
message: `String does not match format: ${schema.format}`,
|
|
129
|
+
keyword: 'format',
|
|
130
|
+
path,
|
|
131
|
+
value
|
|
132
|
+
};
|
|
133
|
+
} else {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const validateNumber = (schema, value, path) => {
|
|
138
|
+
if (schema.multipleOf != null && value % schema.multipleOf !== 0) {
|
|
139
|
+
return {
|
|
140
|
+
message: `Number must be multiple of ${schema.multipleOf}`,
|
|
141
|
+
keyword: 'multipleOf',
|
|
142
|
+
path,
|
|
143
|
+
value
|
|
144
|
+
};
|
|
145
|
+
} else if (schema.minimum != null && value < schema.minimum) {
|
|
146
|
+
return {
|
|
147
|
+
message: `Number must be equal or greater than ${schema.minimum}`,
|
|
148
|
+
keyword: 'minimum',
|
|
149
|
+
path,
|
|
150
|
+
value
|
|
151
|
+
};
|
|
152
|
+
} else if (schema.maximum != null && value > schema.maximum) {
|
|
153
|
+
return {
|
|
154
|
+
message: `Number must be equal or less than ${schema.maximum}`,
|
|
155
|
+
keyword: 'maximum',
|
|
156
|
+
path,
|
|
157
|
+
value
|
|
158
|
+
};
|
|
159
|
+
} else if (schema.exclusiveMaximum === true && schema.maximum != null && value >= schema.maximum) {
|
|
160
|
+
return {
|
|
161
|
+
message: `Number must be less than ${schema.maximum}`,
|
|
162
|
+
keyword: 'exclusiveMaximum',
|
|
163
|
+
path,
|
|
164
|
+
value
|
|
165
|
+
};
|
|
166
|
+
} else if (typeof schema.exclusiveMaximum === 'number' && value >= schema.exclusiveMaximum) {
|
|
167
|
+
return {
|
|
168
|
+
message: `Number must be less than ${schema.exclusiveMaximum}`,
|
|
169
|
+
keyword: 'exclusiveMaximum',
|
|
170
|
+
path,
|
|
171
|
+
value
|
|
172
|
+
};
|
|
173
|
+
} else if (schema.exclusiveMinimum === true && schema.minimum != null && value <= schema.minimum) {
|
|
174
|
+
return {
|
|
175
|
+
message: `Number must be greater than ${schema.minimum}`,
|
|
176
|
+
keyword: 'exclusiveMinimum',
|
|
177
|
+
path,
|
|
178
|
+
value
|
|
179
|
+
};
|
|
180
|
+
} else if (typeof schema.exclusiveMinimum === 'number' && value <= schema.exclusiveMinimum) {
|
|
181
|
+
return {
|
|
182
|
+
message: `Number must be greater than ${schema.exclusiveMinimum}`,
|
|
183
|
+
keyword: 'exclusiveMinimum',
|
|
184
|
+
path,
|
|
185
|
+
value
|
|
186
|
+
};
|
|
187
|
+
} else {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const validateContains = (containsSchema, value, path) => {
|
|
192
|
+
for (let idx = 0; idx < value.length; idx++) {
|
|
193
|
+
if (validateSchema(containsSchema, value[idx], path) === null) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
message: 'Array must contain at least one item matching the contains schema',
|
|
199
|
+
keyword: 'contains',
|
|
200
|
+
path,
|
|
201
|
+
value
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
const validateItems = (itemsSchema, additionalItems, value, path) => {
|
|
205
|
+
let child;
|
|
206
|
+
if (Array.isArray(itemsSchema)) {
|
|
207
|
+
let idx = 0;
|
|
208
|
+
for (idx = 0; idx < itemsSchema.length; idx++) {
|
|
209
|
+
if ((child = validateSchema(itemsSchema[idx], value[idx], `${path}[${idx}]`)) != null) {
|
|
210
|
+
return child;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (idx < value.length) {
|
|
214
|
+
if (additionalItems === true) {
|
|
215
|
+
return null;
|
|
216
|
+
} else if (additionalItems) {
|
|
217
|
+
for (; idx < value.length; idx++) {
|
|
218
|
+
if ((child = validateSchema(additionalItems, value[idx], `${path}[${idx}]`)) != null) {
|
|
219
|
+
return child;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
} else {
|
|
224
|
+
return {
|
|
225
|
+
message: `Array contained ${value.length - idx} more items than items schema`,
|
|
226
|
+
keyword: 'additionalItems',
|
|
227
|
+
path,
|
|
228
|
+
value
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
for (let idx = 0; idx < value.length; idx++) {
|
|
236
|
+
if ((child = validateSchema(itemsSchema, value[idx], `${path}[${idx}]`)) != null) {
|
|
237
|
+
return child;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const validateArray = (schema, value, path) => {
|
|
244
|
+
let child;
|
|
245
|
+
if (schema.minItems != null && value.length < schema.minItems) {
|
|
246
|
+
return {
|
|
247
|
+
message: `Array must have at least ${schema.minItems} items`,
|
|
248
|
+
keyword: 'minItems',
|
|
249
|
+
path,
|
|
250
|
+
value
|
|
251
|
+
};
|
|
252
|
+
} else if (schema.maxItems != null && value.length > schema.maxItems) {
|
|
253
|
+
return {
|
|
254
|
+
message: `Array must have at most ${schema.maxItems} items`,
|
|
255
|
+
keyword: 'maxItems',
|
|
256
|
+
path,
|
|
257
|
+
value
|
|
258
|
+
};
|
|
259
|
+
} else if (schema.uniqueItems && !areArrayValuesUnique(value)) {
|
|
260
|
+
return {
|
|
261
|
+
message: 'Array items must be unique',
|
|
262
|
+
keyword: 'uniqueItems',
|
|
263
|
+
path,
|
|
264
|
+
value
|
|
265
|
+
};
|
|
266
|
+
} else if (schema.contains != null && (child = validateContains(schema.contains, value, path)) != null) {
|
|
267
|
+
return child;
|
|
268
|
+
} else if (schema.items != null && (child = validateItems(schema.items, schema.additionalItems, value, path)) != null) {
|
|
269
|
+
return child;
|
|
270
|
+
} else {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
const validateRequired = (keys, value, path) => {
|
|
275
|
+
for (let idx = 0; idx < keys.length; idx++) {
|
|
276
|
+
if (value[keys[idx]] === undefined) {
|
|
277
|
+
return {
|
|
278
|
+
message: `Required property "${keys[idx]}" is missing`,
|
|
279
|
+
keyword: 'required',
|
|
280
|
+
path: `${path}.${keys[idx]}`,
|
|
281
|
+
value
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
};
|
|
287
|
+
const validateProperties = (properties, value, path) => {
|
|
288
|
+
let child;
|
|
289
|
+
for (const key in properties) {
|
|
290
|
+
if (value[key] !== undefined && (child = validateSchema(properties[key], value[key], `${path}.${key}`)) != null) {
|
|
291
|
+
return child;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return null;
|
|
295
|
+
};
|
|
296
|
+
const validatePatternProperties = (validatedProperties, patternProperties, keys, value, path) => {
|
|
297
|
+
let child;
|
|
298
|
+
for (const pattern in patternProperties) {
|
|
299
|
+
const propertyRe = new RegExp(pattern);
|
|
300
|
+
for (let idx = 0; idx < keys.length; idx++) {
|
|
301
|
+
const key = keys[idx];
|
|
302
|
+
const childSchema = patternProperties[pattern];
|
|
303
|
+
if (propertyRe.test(key)) {
|
|
304
|
+
validatedProperties.add(key);
|
|
305
|
+
if ((child = validateSchema(childSchema, value[key], `${path}.${key}`)) != null) {
|
|
306
|
+
return child;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return null;
|
|
312
|
+
};
|
|
313
|
+
const validateAdditionalProperties = (additionalProperties, properties, visitedPatternProperties, keys, value, path) => {
|
|
314
|
+
if (additionalProperties === true) {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
let child;
|
|
318
|
+
for (let idx = 0; idx < keys.length; idx++) {
|
|
319
|
+
const key = keys[idx];
|
|
320
|
+
if (!visitedPatternProperties.has(key) && !properties?.[key]) {
|
|
321
|
+
if (additionalProperties === false) {
|
|
322
|
+
return {
|
|
323
|
+
message: `Additional property "${key}" is not allowed`,
|
|
324
|
+
keyword: 'additionalProperties',
|
|
325
|
+
path: `${path}.${key}`,
|
|
326
|
+
value: value[key]
|
|
327
|
+
};
|
|
328
|
+
} else if ((child = validateSchema(additionalProperties, value[key], `${path}.${key}`)) != null) {
|
|
329
|
+
return child;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return null;
|
|
334
|
+
};
|
|
335
|
+
const validatePropertyNames = (propertyNames, keys, path) => {
|
|
336
|
+
let child;
|
|
337
|
+
for (let idx = 0; idx < keys.length; idx++) {
|
|
338
|
+
const key = keys[idx];
|
|
339
|
+
if ((child = validateString(propertyNames, key, `${path}.${key}`)) != null) {
|
|
340
|
+
child.message = `Property name "${key}" does not match schema. ${child.message}`;
|
|
341
|
+
return child;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return null;
|
|
345
|
+
};
|
|
346
|
+
const validateDependencies = (dependencies, value, path) => {
|
|
347
|
+
let child;
|
|
348
|
+
for (const key in dependencies) {
|
|
349
|
+
if (value[key] !== undefined) {
|
|
350
|
+
if (Array.isArray(dependencies[key])) {
|
|
351
|
+
for (let idx = 0; idx < dependencies[key].length; idx++) {
|
|
352
|
+
if (value[dependencies[key][idx]] === undefined) {
|
|
353
|
+
return {
|
|
354
|
+
message: `Property "${dependencies[key][idx]}" is required when "${key}" is present`,
|
|
355
|
+
keyword: 'dependencies',
|
|
356
|
+
path: `${path}.${dependencies[key][idx]}`,
|
|
357
|
+
value: undefined
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
} else if (dependencies[key] != null && (child = validateSchema(dependencies[key], value, path)) != null) {
|
|
362
|
+
return child;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return null;
|
|
367
|
+
};
|
|
368
|
+
const validateObject = (schema, value, path) => {
|
|
369
|
+
const keys = Object.keys(value);
|
|
370
|
+
const visitedPatternProperties = new Set();
|
|
371
|
+
let child;
|
|
372
|
+
if (schema.minProperties != null && keys.length < schema.minProperties) {
|
|
373
|
+
return {
|
|
374
|
+
message: `Object must have at least ${schema.minProperties} properties`,
|
|
375
|
+
keyword: 'minProperties',
|
|
376
|
+
path,
|
|
377
|
+
value
|
|
378
|
+
};
|
|
379
|
+
} else if (schema.maxProperties != null && keys.length > schema.maxProperties) {
|
|
380
|
+
return {
|
|
381
|
+
message: `Object must have at most ${schema.maxProperties} properties`,
|
|
382
|
+
keyword: 'maxProperties',
|
|
383
|
+
path,
|
|
384
|
+
value
|
|
385
|
+
};
|
|
386
|
+
} else if (schema.required != null && (child = validateRequired(schema.required, value, path)) != null) {
|
|
387
|
+
return child;
|
|
388
|
+
} else if (schema.properties != null && (child = validateProperties(schema.properties, value, path)) != null) {
|
|
389
|
+
return child;
|
|
390
|
+
} else if (schema.patternProperties != null && (child = validatePatternProperties(visitedPatternProperties, schema.patternProperties, keys, value, path)) != null) {
|
|
391
|
+
return child;
|
|
392
|
+
} else if (schema.additionalProperties != null && (child = validateAdditionalProperties(schema.additionalProperties, schema.properties, visitedPatternProperties, keys, value, path)) != null) {
|
|
393
|
+
return child;
|
|
394
|
+
} else if (schema.propertyNames != null && (child = validatePropertyNames(schema.propertyNames, keys, path)) != null) {
|
|
395
|
+
return child;
|
|
396
|
+
} else if (schema.dependencies != null && (child = validateDependencies(schema.dependencies, value, path)) != null) {
|
|
397
|
+
return child;
|
|
398
|
+
} else {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const validateType = (schemaType, valueType, path) => {
|
|
403
|
+
if (Array.isArray(schemaType)) {
|
|
404
|
+
if (valueType === 'integer' && schemaType.includes('number')) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
return !schemaType.includes(valueType) ? {
|
|
408
|
+
message: `Expected type ${schemaType.join(' or ')}, got ${valueType}`,
|
|
409
|
+
keyword: 'type',
|
|
410
|
+
path,
|
|
411
|
+
value: undefined
|
|
412
|
+
} : null;
|
|
413
|
+
} else {
|
|
414
|
+
if (valueType === 'integer' && schemaType === 'number') {
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
return schemaType !== valueType ? {
|
|
418
|
+
message: `Expected type ${schemaType}, got ${valueType}`,
|
|
419
|
+
keyword: 'type',
|
|
420
|
+
path,
|
|
421
|
+
value: undefined
|
|
422
|
+
} : null;
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const validateAllOf = (schemas, value, path) => {
|
|
426
|
+
let child;
|
|
427
|
+
for (let idx = 0; idx < schemas.length; idx++) {
|
|
428
|
+
if ((child = validateSchema(schemas[idx], value, path)) != null) {
|
|
429
|
+
return child;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return null;
|
|
433
|
+
};
|
|
434
|
+
const validateAnyOf = (schemas, value, path) => {
|
|
435
|
+
let child;
|
|
436
|
+
const cause = [];
|
|
437
|
+
for (let idx = 0; idx < schemas.length; idx++) {
|
|
438
|
+
if ((child = validateSchema(schemas[idx], value, path)) != null) {
|
|
439
|
+
cause.push(child);
|
|
440
|
+
} else {
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return {
|
|
445
|
+
message: 'No schema matched anyOf type',
|
|
446
|
+
keyword: 'anyOf',
|
|
447
|
+
path,
|
|
448
|
+
value,
|
|
449
|
+
cause
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
const validateOneOf = (schemas, value, path) => {
|
|
453
|
+
let child;
|
|
454
|
+
const cause = [];
|
|
455
|
+
for (let idx = 0; idx < schemas.length; idx++) {
|
|
456
|
+
if ((child = validateSchema(schemas[idx], value, path)) != null) {
|
|
457
|
+
cause.push(child);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (cause.length >= schemas.length) {
|
|
461
|
+
return {
|
|
462
|
+
message: 'Value does not match any of the oneOf schemas',
|
|
463
|
+
keyword: 'oneOf',
|
|
464
|
+
path,
|
|
465
|
+
value,
|
|
466
|
+
cause
|
|
467
|
+
};
|
|
468
|
+
} else if (cause.length < schemas.length - 1) {
|
|
469
|
+
return {
|
|
470
|
+
message: `Value matches ${schemas.length - cause.length} schemas, but exactly one is required`,
|
|
471
|
+
keyword: 'oneOf',
|
|
472
|
+
path,
|
|
473
|
+
value,
|
|
474
|
+
cause
|
|
475
|
+
};
|
|
476
|
+
} else {
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
const validateConditional = (ifSchema, thenSchema, elseSchema, value, path) => {
|
|
481
|
+
let child;
|
|
482
|
+
if (validateSchema(ifSchema, value, path) != null) {
|
|
483
|
+
if (elseSchema != null && (child = validateSchema(elseSchema, value, path)) != null) {
|
|
484
|
+
return {
|
|
485
|
+
message: 'Value does not match "else" schema but did not match "if" condition schema',
|
|
486
|
+
keyword: 'else',
|
|
487
|
+
path,
|
|
488
|
+
value,
|
|
489
|
+
cause: [child]
|
|
490
|
+
};
|
|
491
|
+
} else {
|
|
492
|
+
return null;
|
|
493
|
+
}
|
|
494
|
+
} else if (thenSchema != null && (child = validateSchema(thenSchema, value, path)) != null) {
|
|
495
|
+
return {
|
|
496
|
+
message: 'Value does not match "then" schema but did match "if" condition schema',
|
|
497
|
+
keyword: 'then',
|
|
498
|
+
path,
|
|
499
|
+
value,
|
|
500
|
+
cause: [child]
|
|
501
|
+
};
|
|
502
|
+
} else {
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
const validateSchema = (schema, value, path) => {
|
|
507
|
+
if (typeof schema === 'boolean') {
|
|
508
|
+
// Draft 07: Schemas can be booleans
|
|
509
|
+
return !schema ? {
|
|
510
|
+
message: 'Schema is false',
|
|
511
|
+
keyword: 'schema',
|
|
512
|
+
path,
|
|
513
|
+
value: undefined
|
|
514
|
+
} : null;
|
|
515
|
+
}
|
|
516
|
+
const valueType = getValueType(value);
|
|
517
|
+
let child;
|
|
518
|
+
if (schema.type !== undefined && (child = validateType(schema.type, valueType, path)) != null) {
|
|
519
|
+
return child;
|
|
520
|
+
} else if (schema.const !== undefined && !isDeepEqual(value, schema.const)) {
|
|
521
|
+
return {
|
|
522
|
+
message: `Value must be equal to ${JSON.stringify(schema.const)}`,
|
|
523
|
+
keyword: 'const',
|
|
524
|
+
path,
|
|
525
|
+
value
|
|
526
|
+
};
|
|
527
|
+
} else if (schema.enum != null && !isEnumValue(schema.enum, value)) {
|
|
528
|
+
return {
|
|
529
|
+
message: `Value must be one of ${JSON.stringify(schema.enum)}`,
|
|
530
|
+
keyword: 'enum',
|
|
531
|
+
path,
|
|
532
|
+
value
|
|
533
|
+
};
|
|
534
|
+
} else if (schema.allOf != null && (child = validateAllOf(schema.allOf, value, path)) != null) {
|
|
535
|
+
return child;
|
|
536
|
+
} else if (schema.anyOf != null && (child = validateAnyOf(schema.anyOf, value, path)) != null) {
|
|
537
|
+
return child;
|
|
538
|
+
} else if (schema.oneOf != null && (child = validateOneOf(schema.oneOf, value, path)) != null) {
|
|
539
|
+
return child;
|
|
540
|
+
} else if (schema.not != null && validateSchema(schema.not, value, path) == null) {
|
|
541
|
+
return {
|
|
542
|
+
message: 'Value matches the not schema, but should not',
|
|
543
|
+
keyword: 'not',
|
|
544
|
+
path,
|
|
545
|
+
value
|
|
546
|
+
};
|
|
547
|
+
} else if (schema.if != null && (schema.then != null || schema.else != null) && (child = validateConditional(schema.if, schema.then, schema.else, value, path)) != null) {
|
|
548
|
+
return child;
|
|
549
|
+
}
|
|
550
|
+
switch (valueType) {
|
|
551
|
+
case 'string':
|
|
552
|
+
return validateString(schema, value, path);
|
|
553
|
+
case 'number':
|
|
554
|
+
case 'integer':
|
|
555
|
+
return validateNumber(schema, value, path);
|
|
556
|
+
case 'array':
|
|
557
|
+
return validateArray(schema, value, path);
|
|
558
|
+
case 'object':
|
|
559
|
+
return validateObject(schema, value, path);
|
|
560
|
+
default:
|
|
561
|
+
return null;
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
exports.validateSchema = validateSchema;
|
|
565
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","names":["getValueType","value","typeOf","Number","isInteger","Array","isArray","isDeepEqual","a","b","length","idx","keysA","Object","keys","keysB","areArrayValuesUnique","array","i","j","dateRe","dateTimeRe","timeRe","emailRe","hostnameRe","uriRe","validateFormat","format","test","TypeError","isEnumValue","enumValues","validateString","schema","path","minLength","message","keyword","maxLength","pattern","RegExp","validateNumber","multipleOf","minimum","maximum","exclusiveMaximum","exclusiveMinimum","validateContains","containsSchema","validateSchema","validateItems","itemsSchema","additionalItems","child","validateArray","minItems","maxItems","uniqueItems","contains","items","validateRequired","undefined","validateProperties","properties","key","validatePatternProperties","validatedProperties","patternProperties","propertyRe","childSchema","add","validateAdditionalProperties","additionalProperties","visitedPatternProperties","has","validatePropertyNames","propertyNames","validateDependencies","dependencies","validateObject","Set","minProperties","maxProperties","required","validateType","schemaType","valueType","includes","join","validateAllOf","schemas","validateAnyOf","cause","push","validateOneOf","validateConditional","ifSchema","thenSchema","elseSchema","type","const","JSON","stringify","enum","allOf","anyOf","oneOf","not","if","then","else","exports"],"sources":["../src/validate.ts"],"sourcesContent":["import { JSONSchema } from './JSONSchema';\n\nexport interface BaseValidationError {\n message: string;\n path: string;\n keyword: string;\n value: unknown;\n}\n\nexport interface ValidationError extends BaseValidationError {\n cause?: ValidationError[];\n}\n\ntype OneOrMany<T> = T | T[];\n\nconst getValueType = (\n value: unknown\n):\n | 'null'\n | 'boolean'\n | 'object'\n | 'array'\n | 'number'\n | 'integer'\n | 'string'\n | 'symbol'\n | 'undefined'\n | 'bigint'\n | 'function' => {\n const typeOf = typeof value;\n switch (typeOf) {\n case 'number':\n return Number.isInteger(value) ? 'integer' : 'number';\n case 'boolean':\n case 'string':\n return typeOf;\n case 'object':\n if (value === null) {\n return 'null';\n } else if (Array.isArray(value)) {\n return 'array';\n } else {\n return 'object';\n }\n default:\n return typeOf;\n }\n};\n\nconst isDeepEqual = (a: any, b: any): boolean => {\n if (a === b) {\n return true;\n } else if (a === null || b === null) {\n return false;\n } else if (typeof a !== typeof b) {\n return false;\n } else if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) {\n return false;\n }\n for (let idx = 0; idx < a.length; idx++) {\n if (!isDeepEqual(a[idx], b[idx])) return false;\n }\n return true;\n } else if (typeof a === 'object') {\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (!isDeepEqual(keysA, keysB)) {\n return false;\n }\n for (let idx = 0; idx < keysA.length; idx++) {\n if (!isDeepEqual(a[keysA[idx]], b[keysA[idx]])) {\n return false;\n }\n }\n return true;\n } else {\n return false;\n }\n};\n\nconst areArrayValuesUnique = (array: unknown[]): boolean => {\n for (let i = 0; i < array.length; i++) {\n for (let j = 0; j < array.length; j++) {\n if (i !== j && isDeepEqual(array[i], array[j])) {\n return false;\n }\n }\n }\n return true;\n};\n\nconst dateRe = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst dateTimeRe = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z?$/;\nconst timeRe = /^\\d{2}:\\d{2}:\\d{2}$/;\nconst emailRe = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\nconst hostnameRe =\n /^[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])?)*$/;\nconst uriRe = /^https?:\\/\\//;\n\nconst validateFormat = (format: string, value: string): boolean => {\n // NOTE: Left out ipv4 and ipv6\n switch (format) {\n case 'date-time':\n return dateTimeRe.test(value);\n case 'date':\n return dateRe.test(value);\n case 'time':\n return timeRe.test(value);\n case 'email':\n return emailRe.test(value);\n case 'hostname':\n return hostnameRe.test(value);\n case 'uri':\n return uriRe.test(value);\n default:\n throw new TypeError(`Unsupported format \"${format}\"`);\n }\n};\n\nconst isEnumValue = (enumValues: unknown[], value: unknown): boolean => {\n if (!enumValues.length) {\n throw new TypeError('Empty enum array');\n }\n for (let idx = 0; idx < enumValues.length; idx++) {\n if (isDeepEqual(value, enumValues[idx])) {\n return true;\n }\n }\n return false;\n};\n\nconst validateString = (\n schema: JSONSchema,\n value: string,\n path: string\n): ValidationError | null => {\n if (schema.minLength != null && value.length < schema.minLength) {\n return {\n message: `String must be at least ${schema.minLength} characters`,\n keyword: 'minLength',\n path,\n value,\n };\n } else if (schema.maxLength != null && value.length > schema.maxLength) {\n return {\n message: `String must be at most ${schema.maxLength} characters`,\n keyword: 'maxLength',\n path,\n value,\n };\n } else if (schema.pattern != null && !new RegExp(schema.pattern).test(value)) {\n return {\n message: `String does not match pattern: ${schema.pattern}`,\n keyword: 'pattern',\n path,\n value,\n };\n } else if (schema.format != null && !validateFormat(schema.format, value)) {\n return {\n message: `String does not match format: ${schema.format}`,\n keyword: 'format',\n path,\n value,\n };\n } else {\n return null;\n }\n};\n\nconst validateNumber = (\n schema: JSONSchema,\n value: number,\n path: string\n): ValidationError | null => {\n if (schema.multipleOf != null && value % schema.multipleOf !== 0) {\n return {\n message: `Number must be multiple of ${schema.multipleOf}`,\n keyword: 'multipleOf',\n path,\n value,\n };\n } else if (schema.minimum != null && value < schema.minimum) {\n return {\n message: `Number must be equal or greater than ${schema.minimum}`,\n keyword: 'minimum',\n path,\n value,\n };\n } else if (schema.maximum != null && value > schema.maximum) {\n return {\n message: `Number must be equal or less than ${schema.maximum}`,\n keyword: 'maximum',\n path,\n value,\n };\n } else if (\n schema.exclusiveMaximum === true &&\n schema.maximum != null &&\n value >= schema.maximum\n ) {\n return {\n message: `Number must be less than ${schema.maximum}`,\n keyword: 'exclusiveMaximum',\n path,\n value,\n };\n } else if (typeof schema.exclusiveMaximum === 'number' && value >= schema.exclusiveMaximum) {\n return {\n message: `Number must be less than ${schema.exclusiveMaximum}`,\n keyword: 'exclusiveMaximum',\n path,\n value,\n };\n } else if (\n schema.exclusiveMinimum === true &&\n schema.minimum != null &&\n value <= schema.minimum\n ) {\n return {\n message: `Number must be greater than ${schema.minimum}`,\n keyword: 'exclusiveMinimum',\n path,\n value,\n };\n } else if (typeof schema.exclusiveMinimum === 'number' && value <= schema.exclusiveMinimum) {\n return {\n message: `Number must be greater than ${schema.exclusiveMinimum}`,\n keyword: 'exclusiveMinimum',\n path,\n value,\n };\n } else {\n return null;\n }\n};\n\nconst validateContains = (\n containsSchema: JSONSchema,\n value: unknown[],\n path: string\n): ValidationError | null => {\n for (let idx = 0; idx < value.length; idx++) {\n if (validateSchema(containsSchema, value[idx], path) === null) {\n return null;\n }\n }\n return {\n message: 'Array must contain at least one item matching the contains schema',\n keyword: 'contains',\n path,\n value,\n };\n};\n\nconst validateItems = (\n itemsSchema: JSONSchema | JSONSchema[],\n additionalItems: boolean | JSONSchema | undefined,\n value: unknown[],\n path: string\n): ValidationError | null => {\n let child: ValidationError | null;\n if (Array.isArray(itemsSchema)) {\n let idx = 0;\n for (idx = 0; idx < itemsSchema.length; idx++) {\n if ((child = validateSchema(itemsSchema[idx], value[idx], `${path}[${idx}]`)) != null) {\n return child;\n }\n }\n if (idx < value.length) {\n if (additionalItems === true) {\n return null;\n } else if (additionalItems) {\n for (; idx < value.length; idx++) {\n if ((child = validateSchema(additionalItems, value[idx], `${path}[${idx}]`)) != null) {\n return child;\n }\n }\n return null;\n } else {\n return {\n message: `Array contained ${value.length - idx} more items than items schema`,\n keyword: 'additionalItems',\n path,\n value,\n };\n }\n } else {\n return null;\n }\n } else {\n for (let idx = 0; idx < value.length; idx++) {\n if ((child = validateSchema(itemsSchema, value[idx], `${path}[${idx}]`)) != null) {\n return child;\n }\n }\n return null;\n }\n};\n\nconst validateArray = (schema: JSONSchema, value: unknown[], path: string) => {\n let child: ValidationError | null;\n if (schema.minItems != null && value.length < schema.minItems) {\n return {\n message: `Array must have at least ${schema.minItems} items`,\n keyword: 'minItems',\n path,\n value,\n };\n } else if (schema.maxItems != null && value.length > schema.maxItems) {\n return {\n message: `Array must have at most ${schema.maxItems} items`,\n keyword: 'maxItems',\n path,\n value,\n };\n } else if (schema.uniqueItems && !areArrayValuesUnique(value)) {\n return {\n message: 'Array items must be unique',\n keyword: 'uniqueItems',\n path,\n value,\n };\n } else if (\n schema.contains != null &&\n (child = validateContains(schema.contains as JSONSchema, value, path)) != null\n ) {\n return child;\n } else if (\n schema.items != null &&\n (child = validateItems(schema.items, schema.additionalItems, value, path)) != null\n ) {\n return child;\n } else {\n return null;\n }\n};\n\nconst validateRequired = (\n keys: string[],\n value: Record<string, unknown>,\n path: string\n): ValidationError | null => {\n for (let idx = 0; idx < keys.length; idx++) {\n if (value[keys[idx]] === undefined) {\n return {\n message: `Required property \"${keys[idx]}\" is missing`,\n keyword: 'required',\n path: `${path}.${keys[idx]}`,\n value,\n };\n }\n }\n return null;\n};\n\nconst validateProperties = (\n properties: Record<string, JSONSchema>,\n value: Record<string, unknown>,\n path: string\n): ValidationError | null => {\n let child: ValidationError | null;\n for (const key in properties) {\n if (\n value[key] !== undefined &&\n (child = validateSchema(properties[key], value[key], `${path}.${key}`)) != null\n ) {\n return child;\n }\n }\n return null;\n};\n\nconst validatePatternProperties = (\n validatedProperties: Set<string>,\n patternProperties: Record<string, JSONSchema>,\n keys: string[],\n value: Record<string, unknown>,\n path: string\n): ValidationError | null => {\n let child: ValidationError | null;\n for (const pattern in patternProperties) {\n const propertyRe = new RegExp(pattern);\n for (let idx = 0; idx < keys.length; idx++) {\n const key = keys[idx];\n const childSchema = patternProperties[pattern];\n if (propertyRe.test(key)) {\n validatedProperties.add(key);\n if ((child = validateSchema(childSchema, value[key], `${path}.${key}`)) != null) {\n return child;\n }\n }\n }\n }\n return null;\n};\n\nconst validateAdditionalProperties = (\n additionalProperties: boolean | JSONSchema,\n properties: Record<string, JSONSchema> | undefined,\n visitedPatternProperties: Set<string>,\n keys: string[],\n value: Record<string, unknown>,\n path: string\n): ValidationError | null => {\n if (additionalProperties === true) {\n return null;\n }\n let child: ValidationError | null;\n for (let idx = 0; idx < keys.length; idx++) {\n const key = keys[idx];\n if (!visitedPatternProperties.has(key) && !properties?.[key]) {\n if (additionalProperties === false) {\n return {\n message: `Additional property \"${key}\" is not allowed`,\n keyword: 'additionalProperties',\n path: `${path}.${key}`,\n value: value[key],\n };\n } else if (\n (child = validateSchema(additionalProperties, value[key], `${path}.${key}`)) != null\n ) {\n return child;\n }\n }\n }\n return null;\n};\n\nconst validatePropertyNames = (\n propertyNames: JSONSchema,\n keys: string[],\n path: string\n): ValidationError | null => {\n let child: ValidationError | null;\n for (let idx = 0; idx < keys.length; idx++) {\n const key = keys[idx];\n if ((child = validateString(propertyNames, key, `${path}.${key}`)) != null) {\n child.message = `Property name \"${key}\" does not match schema. ${child.message}`;\n return child;\n }\n }\n return null;\n};\n\nconst validateDependencies = (\n dependencies: Record<string, JSONSchema | string[] | undefined>,\n value: Record<string, unknown>,\n path: string\n): ValidationError | null => {\n let child: ValidationError | null;\n for (const key in dependencies) {\n if (value[key] !== undefined) {\n if (Array.isArray(dependencies[key])) {\n for (let idx = 0; idx < dependencies[key].length; idx++) {\n if (value[dependencies[key][idx]] === undefined) {\n return {\n message: `Property \"${dependencies[key][idx]}\" is required when \"${key}\" is present`,\n keyword: 'dependencies',\n path: `${path}.${dependencies[key][idx]}`,\n value: undefined,\n };\n }\n }\n } else if (\n dependencies[key] != null &&\n (child = validateSchema(dependencies[key], value, path)) != null\n ) {\n return child;\n }\n }\n }\n return null;\n};\n\nconst validateObject = (\n schema: JSONSchema,\n value: Record<string, unknown>,\n path: string\n): ValidationError | null => {\n const keys = Object.keys(value);\n const visitedPatternProperties = new Set<string>();\n let child: ValidationError | null;\n if (schema.minProperties != null && keys.length < schema.minProperties) {\n return {\n message: `Object must have at least ${schema.minProperties} properties`,\n keyword: 'minProperties',\n path,\n value,\n };\n } else if (schema.maxProperties != null && keys.length > schema.maxProperties) {\n return {\n message: `Object must have at most ${schema.maxProperties} properties`,\n keyword: 'maxProperties',\n path,\n value,\n };\n } else if (\n schema.required != null &&\n (child = validateRequired(schema.required, value, path)) != null\n ) {\n return child;\n } else if (\n schema.properties != null &&\n (child = validateProperties(schema.properties, value, path)) != null\n ) {\n return child;\n } else if (\n schema.patternProperties != null &&\n (child = validatePatternProperties(\n visitedPatternProperties,\n schema.patternProperties,\n keys,\n value,\n path\n )) != null\n ) {\n return child;\n } else if (\n schema.additionalProperties != null &&\n (child = validateAdditionalProperties(\n schema.additionalProperties,\n schema.properties,\n visitedPatternProperties,\n keys,\n value,\n path\n )) != null\n ) {\n return child;\n } else if (\n schema.propertyNames != null &&\n (child = validatePropertyNames(schema.propertyNames as JSONSchema, keys, path)) != null\n ) {\n return child;\n } else if (\n schema.dependencies != null &&\n (child = validateDependencies(schema.dependencies, value, path)) != null\n ) {\n return child;\n } else {\n return null;\n }\n};\n\nconst validateType = (\n schemaType: OneOrMany<'null' | 'boolean' | 'object' | 'array' | 'number' | 'integer' | 'string'>,\n valueType: string,\n path: string\n): ValidationError | null => {\n if (Array.isArray(schemaType)) {\n if (valueType === 'integer' && schemaType.includes('number')) {\n return null;\n }\n return !schemaType.includes(valueType as any)\n ? {\n message: `Expected type ${schemaType.join(' or ')}, got ${valueType}`,\n keyword: 'type',\n path,\n value: undefined,\n }\n : null;\n } else {\n if (valueType === 'integer' && schemaType === 'number') {\n return null;\n }\n return schemaType !== valueType\n ? {\n message: `Expected type ${schemaType}, got ${valueType}`,\n keyword: 'type',\n path,\n value: undefined,\n }\n : null;\n }\n};\n\nconst validateAllOf = (\n schemas: JSONSchema[],\n value: unknown,\n path: string\n): ValidationError | null => {\n let child: ValidationError | null;\n for (let idx = 0; idx < schemas.length; idx++) {\n if ((child = validateSchema(schemas[idx], value, path)) != null) {\n return child;\n }\n }\n return null;\n};\n\nconst validateAnyOf = (\n schemas: JSONSchema[],\n value: unknown,\n path: string\n): ValidationError | null => {\n let child: ValidationError | null;\n const cause: ValidationError[] = [];\n for (let idx = 0; idx < schemas.length; idx++) {\n if ((child = validateSchema(schemas[idx], value, path)) != null) {\n cause.push(child);\n } else {\n return null;\n }\n }\n return {\n message: 'No schema matched anyOf type',\n keyword: 'anyOf',\n path,\n value,\n cause,\n };\n};\n\nconst validateOneOf = (\n schemas: JSONSchema[],\n value: unknown,\n path: string\n): ValidationError | null => {\n let child: ValidationError | null;\n const cause: ValidationError[] = [];\n for (let idx = 0; idx < schemas.length; idx++) {\n if ((child = validateSchema(schemas[idx], value, path)) != null) {\n cause.push(child);\n }\n }\n if (cause.length >= schemas.length) {\n return {\n message: 'Value does not match any of the oneOf schemas',\n keyword: 'oneOf',\n path,\n value,\n cause,\n };\n } else if (cause.length < schemas.length - 1) {\n return {\n message: `Value matches ${schemas.length - cause.length} schemas, but exactly one is required`,\n keyword: 'oneOf',\n path,\n value,\n cause,\n };\n } else {\n return null;\n }\n};\n\nconst validateConditional = (\n ifSchema: JSONSchema,\n thenSchema: JSONSchema | undefined,\n elseSchema: JSONSchema | undefined,\n value: unknown,\n path: string\n): ValidationError | null => {\n let child: ValidationError | null;\n if (validateSchema(ifSchema, value, path) != null) {\n if (elseSchema != null && (child = validateSchema(elseSchema, value, path)) != null) {\n return {\n message: 'Value does not match \"else\" schema but did not match \"if\" condition schema',\n keyword: 'else',\n path,\n value,\n cause: [child],\n };\n } else {\n return null;\n }\n } else if (thenSchema != null && (child = validateSchema(thenSchema, value, path)) != null) {\n return {\n message: 'Value does not match \"then\" schema but did match \"if\" condition schema',\n keyword: 'then',\n path,\n value,\n cause: [child],\n };\n } else {\n return null;\n }\n};\n\nexport const validateSchema = (\n schema: JSONSchema,\n value: unknown,\n path: string\n): ValidationError | null => {\n if (typeof schema === 'boolean') {\n // Draft 07: Schemas can be booleans\n return !schema\n ? {\n message: 'Schema is false',\n keyword: 'schema',\n path,\n value: undefined,\n }\n : null;\n }\n\n const valueType = getValueType(value);\n let child: ValidationError | null;\n if (schema.type !== undefined && (child = validateType(schema.type, valueType, path)) != null) {\n return child;\n } else if (schema.const !== undefined && !isDeepEqual(value, schema.const)) {\n return {\n message: `Value must be equal to ${JSON.stringify(schema.const)}`,\n keyword: 'const',\n path,\n value,\n };\n } else if (schema.enum != null && !isEnumValue(schema.enum, value)) {\n return {\n message: `Value must be one of ${JSON.stringify(schema.enum)}`,\n keyword: 'enum',\n path,\n value,\n };\n } else if (schema.allOf != null && (child = validateAllOf(schema.allOf, value, path)) != null) {\n return child;\n } else if (schema.anyOf != null && (child = validateAnyOf(schema.anyOf, value, path)) != null) {\n return child;\n } else if (schema.oneOf != null && (child = validateOneOf(schema.oneOf, value, path)) != null) {\n return child;\n } else if (schema.not != null && validateSchema(schema.not, value, path) == null) {\n return {\n message: 'Value matches the not schema, but should not',\n keyword: 'not',\n path,\n value,\n };\n } else if (\n schema.if != null &&\n (schema.then != null || schema.else != null) &&\n (child = validateConditional(\n schema.if as JSONSchema,\n schema.then as JSONSchema | undefined,\n schema.else as JSONSchema | undefined,\n value,\n path\n )) != null\n ) {\n return child;\n }\n\n switch (valueType) {\n case 'string':\n return validateString(schema, value as string, path);\n case 'number':\n case 'integer':\n return validateNumber(schema, value as number, path);\n case 'array':\n return validateArray(schema, value as unknown[], path);\n case 'object':\n return validateObject(schema, value as Record<string, unknown>, path);\n default:\n return null;\n }\n};\n"],"mappings":";;;;;;AAeA,MAAMA,YAAY,GAChBC,KAAc,IAYE;EAChB,MAAMC,MAAM,GAAG,OAAOD,KAAK;EAC3B,QAAQC,MAAM;IACZ,KAAK,QAAQ;MACX,OAAOC,MAAM,CAACC,SAAS,CAACH,KAAK,CAAC,GAAG,SAAS,GAAG,QAAQ;IACvD,KAAK,SAAS;IACd,KAAK,QAAQ;MACX,OAAOC,MAAM;IACf,KAAK,QAAQ;MACX,IAAID,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,MAAM;MACf,CAAC,MAAM,IAAII,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,EAAE;QAC/B,OAAO,OAAO;MAChB,CAAC,MAAM;QACL,OAAO,QAAQ;MACjB;IACF;MACE,OAAOC,MAAM;EACjB;AACF,CAAC;AAED,MAAMK,WAAW,GAAGA,CAACC,CAAM,EAAEC,CAAM,KAAc;EAC/C,IAAID,CAAC,KAAKC,CAAC,EAAE;IACX,OAAO,IAAI;EACb,CAAC,MAAM,IAAID,CAAC,KAAK,IAAI,IAAIC,CAAC,KAAK,IAAI,EAAE;IACnC,OAAO,KAAK;EACd,CAAC,MAAM,IAAI,OAAOD,CAAC,KAAK,OAAOC,CAAC,EAAE;IAChC,OAAO,KAAK;EACd,CAAC,MAAM,IAAIJ,KAAK,CAACC,OAAO,CAACE,CAAC,CAAC,EAAE;IAC3B,IAAI,CAACH,KAAK,CAACC,OAAO,CAACG,CAAC,CAAC,IAAID,CAAC,CAACE,MAAM,KAAKD,CAAC,CAACC,MAAM,EAAE;MAC9C,OAAO,KAAK;IACd;IACA,KAAK,IAAIC,GAAG,GAAG,CAAC,EAAEA,GAAG,GAAGH,CAAC,CAACE,MAAM,EAAEC,GAAG,EAAE,EAAE;M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GAAG,EAAE1G,KAAK,EAAEiC,IAAI,CAAC,IAAI,IAAI,EAAE;IAChF,OAAO;MACLE,OAAO,EAAE,8CAA8C;MACvDC,OAAO,EAAE,KAAK;MACdH,IAAI;MACJjC;IACF,CAAC;EACH,CAAC,MAAM,IACLgC,MAAM,CAAC2E,EAAE,IAAI,IAAI,KAChB3E,MAAM,CAAC4E,IAAI,IAAI,IAAI,IAAI5E,MAAM,CAAC6E,IAAI,IAAI,IAAI,CAAC,IAC5C,CAACzD,KAAK,GAAG0C,mBAAmB,CAC1B9D,MAAM,CAAC2E,EAAE,EACT3E,MAAM,CAAC4E,IAAI,EACX5E,MAAM,CAAC6E,IAAI,EACX7G,KAAK,EACLiC,IACF,CAAC,KAAK,IAAI,EACV;IACA,OAAOmB,KAAK;EACd;EAEA,QAAQiC,SAAS;IACf,KAAK,QAAQ;MACX,OAAOtD,cAAc,CAACC,MAAM,EAAEhC,KAAK,EAAYiC,IAAI,CAAC;IACtD,KAAK,QAAQ;IACb,KAAK,SAAS;MACZ,OAAOO,cAAc,CAACR,MAAM,EAAEhC,KAAK,EAAYiC,IAAI,CAAC;IACtD,KAAK,OAAO;MACV,OAAOoB,aAAa,CAACrB,MAAM,EAAEhC,KAAK,EAAeiC,IAAI,CAAC;IACxD,KAAK,QAAQ;MACX,OAAO6C,cAAc,CAAC9C,MAAM,EAAEhC,KAAK,EAA6BiC,IAAI,CAAC;IACvE;MACE,OAAO,IAAI;EACf;AACF,CAAC;AAAC6E,OAAA,CAAA9D,cAAA,GAAAA,cAAA","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@expo/schema-utils",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reusable JSON Schema (Draft 04) validation library for Expo",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./build/index.js",
|
|
7
|
+
"types": "./build/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"build"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc --emitDeclarationOnly && babel src --out-dir build --extensions \".ts\" --source-maps --ignore \"src/**/__mocks__/*\",\"src/**/__tests__/*\"",
|
|
13
|
+
"clean": "expo-module clean",
|
|
14
|
+
"lint": "expo-module lint",
|
|
15
|
+
"generate": "node ./scripts/generate.js",
|
|
16
|
+
"prepare": "yarn run clean && yarn run build",
|
|
17
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
18
|
+
"test": "expo-module test",
|
|
19
|
+
"typecheck": "expo-module typecheck"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/expo/expo/tree/main/packages/@expo/schema-utils#readme",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/expo/expo.git",
|
|
25
|
+
"directory": "packages/@expo/schema-utils"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/expo/expo/issues"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"expo-module-scripts": "^5.0.0",
|
|
32
|
+
"json-schema-to-typescript": "^14.0.5"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|