@dcl/schema-validator-component
v0.2.2
Published
Schema validator component for core components library
Readme
Schema Validator Component (@dcl/schema-validator-component)
A component that exposes a middleware to be used to validate JSON schemas in HTTP bodies.
Features
- Validation of AJV schemas.
Usage
import { createSchemaValidatorComponent } from '@dcl/schema-validator-component'
const schema = {
type: 'object',
properties: {
aTestProp: {
type: 'string'
}
},
required: ['aTestProp']
}
const { withSchemaValidatorMiddleware } = createSchemaValidatorComponent(schema)
router.post('/v1/test', withSchemaValidatorMiddleware(schema))