aboutsummaryrefslogblamecommitdiffstats
path: root/src/utils/schema_validator.ts
blob: 8132f7414857aae910fa7134117661072bb1c1c0 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                                      
                                                                                       
                                                    

                              
                                 
                   
                                         

                                                                                
                                                              

                                                                        
                                                         

     
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);
    }
}