1 | import {Schema, Validator, ValidatorResult} from 'jsonschema';
|
2 |
|
3 | export {ValidatorResult};
|
4 |
|
5 | export class JsonSchema {
|
6 | constructor(private schema: Schema) {}
|
7 |
|
8 | private readonly validator = new Validator();
|
9 |
|
10 | validate<T>(document: T): ValidatorResult {
|
11 | return this.validator.validate(document, this.schema, {allowUnknownAttributes: false});
|
12 | }
|
13 | } |
\ | No newline at end of file |