ajv-formats
ajv-formats copied to clipboard
How to use it with typescript for type safety?
How can I use this package with type safety? Is there any way to extend JsonScehamType<T> to includes the types for ajv-format? I couldn't find a way to do that.
import { JSONSchemaType } from 'ajv';
type Example = {
age: number;
name: string;
};
const sample: JSONSchemaType<Example> = {
type: 'object',
properties: {
age: { type: ['integer'] },
name: {type: ['string'], format: ['']}
},
};
In the above example I want to apply some formats to name
but it's type is string
.
thanks.