Provider interface for creating validators from JSON Schemas
This is the main extension point for custom validator implementations. Implementations should:
class MyValidatorProvider implements jsonSchemaValidator { getValidator<T>(schema: JsonSchemaType<T>): JsonSchemaValidator<T> { // Compile/cache validator from schema return (input: unknown) => { // Validate input against schema if (valid) { return { valid: true, data: input as T, errorMessage: undefined }; } else { return { valid: false, data: undefined, errorMessage: 'Error details' }; } }; }} Copy
class MyValidatorProvider implements jsonSchemaValidator { getValidator<T>(schema: JsonSchemaType<T>): JsonSchemaValidator<T> { // Compile/cache validator from schema return (input: unknown) => { // Validate input against schema if (valid) { return { valid: true, data: input as T, errorMessage: undefined }; } else { return { valid: false, data: undefined, errorMessage: 'Error details' }; } }; }}
Create a validator for the given JSON Schema
Standard JSON Schema object
A validator function that can be called multiple times
Provider interface for creating validators from JSON Schemas
This is the main extension point for custom validator implementations. Implementations should:
Example