11# Class: SchemaValidator
22
3- A validator for [ JSON-schemas ] ( http ://json-schema.org/ )
3+ A validator wrapping (AJV) [ https ://github.com/ajv-validator/ajv ]
44
55
66## Constructors
77
88
99
10- \+ ** new SchemaValidator** (): * [ SchemaValidator] ( #class-schemavalidator ) *
10+ \+ ** new SchemaValidator** (` newSchemas ` : object [ ] ): * [ SchemaValidator] ( #class-schemavalidator ) *
1111
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 ) *
1313
1414Instantiates a SchemaValidator instance
1515
16+ ** Parameters:**
17+
18+ Name | Type | Default |
19+ ------ | ------ | ------ |
20+ ` newSchemas ` | object[ ] | [ ] |
21+
1622** Returns:** * [ SchemaValidator] ( #class-schemavalidator ) *
1723
1824## Methods
1925
2026### addSchema
2127
22- ▸ ** addSchema** (` schema ` : ` Schema ` ): * void*
28+ ▸ ** addSchema** (` schemaObjectOrArray ` : object | object [ ] ): * void*
2329
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 ) *
2531
2632Add a schema to the validator. All schemas and sub-schemas must be added to
2733the validator before the ` validate ` and ` isValid ` methods can be called with
2834instances of that schema.
2935
3036** Parameters:**
3137
32- Name | Type | Description |
33- ------ | ------ | ------ |
34- ` schema ` | ` Schema ` | The schema to add |
38+ Name | Type |
39+ ------ | ------ |
40+ ` schemaObjectOrArray ` | object &# 124 ; object [ ] |
3541
3642** Returns:** * void*
3743
3844___
3945
4046### isValid
4147
42- ▸ ** isValid** (` instance ` : any, ` schema ` : ` Schema ` ): * boolean*
48+ ▸ ** isValid** (` instance ` : any, ` schema ` : object ): * boolean*
4349
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 ) *
4551
4652Check whether an instance properly adheres to a JSON schema
4753
@@ -50,7 +56,7 @@ Check whether an instance properly adheres to a JSON schema
5056Name | Type | Description |
5157------ | ------ | ------ |
5258` instance ` | any | JS object in question |
53- ` schema ` | ` Schema ` | Schema to check against |
59+ ` schema ` | object | Schema to check against |
5460
5561** Returns:** * boolean*
5662
6066
6167### validate
6268
63- ▸ ** validate** (` instance ` : any, ` schema ` : ` Schema ` ): * ` ValidatorResult ` *
69+ ▸ ** validate** (` instance ` : any, ` schema ` : object ): * Ajv *
6470
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 ) *
6672
6773Validate the JS object conforms to a specific JSON schema
6874
@@ -71,12 +77,13 @@ Validate the JS object conforms to a specific JSON schema
7177Name | Type | Description |
7278------ | ------ | ------ |
7379` instance ` | any | JS object in question |
74- ` schema ` | ` Schema ` | Schema to check against |
80+ ` schema ` | object | Schema to check against |
7581
76- ** Returns:** * ` ValidatorResult ` *
82+ ** Returns:** * Ajv *
7783
7884The results of the validation
7985
86+
8087<hr />
8188
8289
0 commit comments