@cfworker/json-schema 4.0.0 → 4.0.2
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/dist/commonjs/package.json +3 -0
- package/dist/esm/deep-compare-strict.d.ts +1 -0
- package/dist/esm/dereference.d.ts +7 -0
- package/dist/esm/format.d.ts +2 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/pointer.d.ts +2 -0
- package/dist/esm/types.d.ts +72 -0
- package/dist/esm/ucs2-length.d.ts +1 -0
- package/dist/esm/validate.d.ts +3 -0
- package/dist/esm/validator.d.ts +10 -0
- package/package.json +33 -26
- package/src/deep-compare-strict.d.ts +1 -0
- package/src/deep-compare-strict.js +39 -0
- package/src/dereference.d.ts +12 -0
- package/src/dereference.js +148 -0
- package/src/format.d.ts +2 -0
- package/src/format.js +137 -0
- package/src/index.d.ts +8 -0
- package/src/index.js +8 -0
- package/src/pointer.d.ts +2 -0
- package/src/pointer.js +6 -0
- package/src/types.d.ts +79 -0
- package/src/types.js +6 -0
- package/src/ucs2-length.d.ts +1 -0
- package/src/ucs2-length.js +17 -0
- package/src/validate.d.ts +13 -0
- package/src/validate.js +1099 -0
- package/src/validator.d.ts +14 -0
- package/src/validator.js +29 -0
- package/dist/tsconfig.cjs.tsbuildinfo +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/{types → commonjs}/deep-compare-strict.d.ts +0 -0
- /package/dist/{cjs → commonjs}/deep-compare-strict.js +0 -0
- /package/dist/{types → commonjs}/dereference.d.ts +0 -0
- /package/dist/{cjs → commonjs}/dereference.js +0 -0
- /package/dist/{types → commonjs}/format.d.ts +0 -0
- /package/dist/{cjs → commonjs}/format.js +0 -0
- /package/dist/{types → commonjs}/index.d.ts +0 -0
- /package/dist/{cjs → commonjs}/index.js +0 -0
- /package/dist/{types → commonjs}/pointer.d.ts +0 -0
- /package/dist/{cjs → commonjs}/pointer.js +0 -0
- /package/dist/{types → commonjs}/types.d.ts +0 -0
- /package/dist/{cjs → commonjs}/types.js +0 -0
- /package/dist/{types → commonjs}/ucs2-length.d.ts +0 -0
- /package/dist/{cjs → commonjs}/ucs2-length.js +0 -0
- /package/dist/{types → commonjs}/validate.d.ts +0 -0
- /package/dist/{cjs → commonjs}/validate.js +0 -0
- /package/dist/{types → commonjs}/validator.d.ts +0 -0
- /package/dist/{cjs → commonjs}/validator.js +0 -0
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type SchemaDraft = '4' | '7' | '2019-09' | '2020-12';
|
|
2
|
+
export declare const enum OutputFormat {
|
|
3
|
+
Flag = 1,
|
|
4
|
+
Basic = 2,
|
|
5
|
+
Detailed = 4
|
|
6
|
+
}
|
|
7
|
+
export type InstanceType =
|
|
8
|
+
| 'array'
|
|
9
|
+
| 'boolean'
|
|
10
|
+
| 'integer'
|
|
11
|
+
| 'null'
|
|
12
|
+
| 'number'
|
|
13
|
+
| 'object'
|
|
14
|
+
| 'string';
|
|
15
|
+
export interface Schema {
|
|
16
|
+
$id?: string;
|
|
17
|
+
$anchor?: string;
|
|
18
|
+
$recursiveAnchor?: boolean;
|
|
19
|
+
$ref?: string;
|
|
20
|
+
$recursiveRef?: '#';
|
|
21
|
+
$schema?: string;
|
|
22
|
+
$comment?: string;
|
|
23
|
+
$defs?: any;
|
|
24
|
+
$vocabulary?: Record<string, boolean>;
|
|
25
|
+
type?: InstanceType | InstanceType[];
|
|
26
|
+
const?: any;
|
|
27
|
+
enum?: any[];
|
|
28
|
+
required?: string[];
|
|
29
|
+
not?: Schema;
|
|
30
|
+
anyOf?: Schema[];
|
|
31
|
+
allOf?: Schema[];
|
|
32
|
+
oneOf?: Schema[];
|
|
33
|
+
if?: Schema;
|
|
34
|
+
then?: Schema;
|
|
35
|
+
else?: Schema;
|
|
36
|
+
format?: string;
|
|
37
|
+
properties?: Record<string | number, Schema | boolean>;
|
|
38
|
+
patternProperties?: Record<string, Schema | boolean>;
|
|
39
|
+
additionalProperties?: Schema | boolean;
|
|
40
|
+
unevaluatedProperties?: Schema | boolean;
|
|
41
|
+
minProperties?: number;
|
|
42
|
+
maxProperties?: number;
|
|
43
|
+
propertyNames?: Schema;
|
|
44
|
+
dependentRequired?: Record<string, string[]>;
|
|
45
|
+
dependentSchemas?: Record<string, Schema>;
|
|
46
|
+
dependencies?: Record<string, Schema | string[]>;
|
|
47
|
+
prefixItems?: Array<Schema | boolean>;
|
|
48
|
+
items?: Schema | boolean | Array<Schema | boolean>;
|
|
49
|
+
additionalItems?: Schema | boolean;
|
|
50
|
+
unevaluatedItems?: Schema | boolean;
|
|
51
|
+
contains?: Schema | boolean;
|
|
52
|
+
minContains?: number;
|
|
53
|
+
maxContains?: number;
|
|
54
|
+
minItems?: number;
|
|
55
|
+
maxItems?: number;
|
|
56
|
+
uniqueItems?: boolean;
|
|
57
|
+
minimum?: number;
|
|
58
|
+
maximum?: number;
|
|
59
|
+
exclusiveMinimum?: number | boolean;
|
|
60
|
+
exclusiveMaximum?: number | boolean;
|
|
61
|
+
multipleOf?: number;
|
|
62
|
+
minLength?: number;
|
|
63
|
+
maxLength?: number;
|
|
64
|
+
pattern?: string;
|
|
65
|
+
__absolute_ref__?: string;
|
|
66
|
+
__absolute_recursive_ref__?: string;
|
|
67
|
+
__absolute_uri__?: string;
|
|
68
|
+
[key: string]: any;
|
|
69
|
+
}
|
|
70
|
+
export interface OutputUnit {
|
|
71
|
+
keyword: string;
|
|
72
|
+
keywordLocation: string;
|
|
73
|
+
instanceLocation: string;
|
|
74
|
+
error: string;
|
|
75
|
+
}
|
|
76
|
+
export interface ValidationResult {
|
|
77
|
+
valid: boolean;
|
|
78
|
+
errors: OutputUnit[];
|
|
79
|
+
}
|
package/src/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ucs2length(s: string): number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function ucs2length(s) {
|
|
2
|
+
let result = 0;
|
|
3
|
+
let length = s.length;
|
|
4
|
+
let index = 0;
|
|
5
|
+
let charCode;
|
|
6
|
+
while (index < length) {
|
|
7
|
+
result++;
|
|
8
|
+
charCode = s.charCodeAt(index++);
|
|
9
|
+
if (charCode >= 0xd800 && charCode <= 0xdbff && index < length) {
|
|
10
|
+
charCode = s.charCodeAt(index);
|
|
11
|
+
if ((charCode & 0xfc00) == 0xdc00) {
|
|
12
|
+
index++;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Schema, SchemaDraft, ValidationResult } from './types.js';
|
|
2
|
+
export type Evaluated = Record<string | number, boolean>;
|
|
3
|
+
export declare function validate(
|
|
4
|
+
instance: any,
|
|
5
|
+
schema: Schema | boolean,
|
|
6
|
+
draft?: SchemaDraft,
|
|
7
|
+
lookup?: Record<string, Schema | boolean>,
|
|
8
|
+
shortCircuit?: boolean,
|
|
9
|
+
recursiveAnchor?: Schema | null,
|
|
10
|
+
instanceLocation?: string,
|
|
11
|
+
schemaLocation?: string,
|
|
12
|
+
evaluated?: Evaluated
|
|
13
|
+
): ValidationResult;
|