blob: 8132f7414857aae910fa7134117661072bb1c1c0 (
plain) (
tree)
|
|
import {Validator, ValidatorResult} from 'jsonschema';
import {ecSignatureSchema, ecSignatureParameter} from '../schemas/ec_signature_schema';
import {tokenSchema} from '../schemas/token_schema';
export class SchemaValidator {
private validator: Validator;
constructor() {
this.validator = new Validator();
this.validator.addSchema(ecSignatureParameter, ecSignatureParameter.id);
this.validator.addSchema(ecSignatureSchema, ecSignatureSchema.id);
this.validator.addSchema(tokenSchema, tokenSchema.id);
}
public validate(instance: object, schema: Schema): ValidatorResult {
return this.validator.validate(instance, schema);
}
}
|