1
1
# Class: SchemaValidator
2
2
3
- A validator for [ JSON-schemas ] ( http ://json-schema.org/ )
3
+ A validator wrapping (AJV) [ https ://github.com/ajv-validator/ajv ]
4
4
5
5
6
6
## Constructors
7
7
8
8
9
9
10
- \+ ** new SchemaValidator** (): * [ SchemaValidator] ( #class-schemavalidator ) *
10
+ \+ ** new SchemaValidator** (` newSchemas ` : object [ ] ): * [ SchemaValidator] ( #class-schemavalidator ) *
11
11
12
- * Defined in [ schema_validator.ts:15 ] ( https://github.com/0xProject/0x-monorepo /blob/34538f2ce/packages/ json-schemas/src/schema_validator.ts#L15 ) *
12
+ * Defined in [ schema_validator.ts:11 ] ( https://github.com/0xProject/tools /blob/c64730cff/ json-schemas/src/schema_validator.ts#L11 ) *
13
13
14
14
Instantiates a SchemaValidator instance
15
15
16
+ ** Parameters:**
17
+
18
+ Name | Type | Default |
19
+ ------ | ------ | ------ |
20
+ ` newSchemas ` | object[ ] | [ ] |
21
+
16
22
** Returns:** * [ SchemaValidator] ( #class-schemavalidator ) *
17
23
18
24
## Methods
19
25
20
26
### addSchema
21
27
22
- ▸ ** addSchema** (` schema ` : ` Schema ` ): * void*
28
+ ▸ ** addSchema** (` schemaObjectOrArray ` : object | object [ ] ): * void*
23
29
24
- * Defined in [ schema_validator.ts:32 ] ( https://github.com/0xProject/0x-monorepo /blob/34538f2ce/packages/ json-schemas/src/schema_validator.ts#L32 ) *
30
+ * Defined in [ schema_validator.ts:26 ] ( https://github.com/0xProject/tools /blob/c64730cff/ json-schemas/src/schema_validator.ts#L26 ) *
25
31
26
32
Add a schema to the validator. All schemas and sub-schemas must be added to
27
33
the validator before the ` validate ` and ` isValid ` methods can be called with
28
34
instances of that schema.
29
35
30
36
** Parameters:**
31
37
32
- Name | Type | Description |
33
- ------ | ------ | ------ |
34
- ` schema ` | ` Schema ` | The schema to add |
38
+ Name | Type |
39
+ ------ | ------ |
40
+ ` schemaObjectOrArray ` | object &# 124 ; object [ ] |
35
41
36
42
** Returns:** * void*
37
43
38
44
___
39
45
40
46
### isValid
41
47
42
- ▸ ** isValid** (` instance ` : any, ` schema ` : ` Schema ` ): * boolean*
48
+ ▸ ** isValid** (` instance ` : any, ` schema ` : object ): * boolean*
43
49
44
- * Defined in [ schema_validator.ts:57 ] ( https://github.com/0xProject/0x-monorepo /blob/34538f2ce/packages/ json-schemas/src/schema_validator.ts#L57 ) *
50
+ * Defined in [ schema_validator.ts:59 ] ( https://github.com/0xProject/tools /blob/c64730cff/ json-schemas/src/schema_validator.ts#L59 ) *
45
51
46
52
Check whether an instance properly adheres to a JSON schema
47
53
@@ -50,7 +56,7 @@ Check whether an instance properly adheres to a JSON schema
50
56
Name | Type | Description |
51
57
------ | ------ | ------ |
52
58
` instance ` | any | JS object in question |
53
- ` schema ` | ` Schema ` | Schema to check against |
59
+ ` schema ` | object | Schema to check against |
54
60
55
61
** Returns:** * boolean*
56
62
60
66
61
67
### validate
62
68
63
- ▸ ** validate** (` instance ` : any, ` schema ` : ` Schema ` ): * ` ValidatorResult ` *
69
+ ▸ ** validate** (` instance ` : any, ` schema ` : object ): * Ajv *
64
70
65
- * Defined in [ schema_validator.ts:46 ] ( https://github.com/0xProject/0x-monorepo /blob/34538f2ce/packages/ json-schemas/src/schema_validator.ts#L46 ) *
71
+ * Defined in [ schema_validator.ts:49 ] ( https://github.com/0xProject/tools /blob/c64730cff/ json-schemas/src/schema_validator.ts#L49 ) *
66
72
67
73
Validate the JS object conforms to a specific JSON schema
68
74
@@ -71,12 +77,13 @@ Validate the JS object conforms to a specific JSON schema
71
77
Name | Type | Description |
72
78
------ | ------ | ------ |
73
79
` instance ` | any | JS object in question |
74
- ` schema ` | ` Schema ` | Schema to check against |
80
+ ` schema ` | object | Schema to check against |
75
81
76
- ** Returns:** * ` ValidatorResult ` *
82
+ ** Returns:** * Ajv *
77
83
78
84
The results of the validation
79
85
86
+
80
87
<hr />
81
88
82
89
0 commit comments