@springworks/schema-validator
v3005.335.1
Published
Wraps json-schema validator and sets default custom formats.
Downloads
1,780
Readme
@springworks/schema-validator
Wraps json-schema validator and sets default custom formats.
yarn add @springworks/schema-validator
Usage
import { createValidator, ValidationError } from '@springworks/schema-validator';
const validate = createValidator({
title: 'Test schema',
type: 'object',
properties: {
firstName: {
type: 'string',
},
lastName: {
type: 'string',
},
},
required: ['firstName', 'lastName'],
});
validate(obj);
Throws ValidationError
which will contain a descriptive message property about what actually failed validation.