Open AlfieriChou opened 2 years ago
import Ajv from 'https://esm.sh/ajv@8.6.1' const schema = { type: 'object', properties: { a: {type: 'string' }, b: { type: 'number' } }, required: ['a'] } const ajv: Ajv = new Ajv() const start = async (): Promise<any> => { const data: boolean = ajv.validate(schema, { a: '1', b: '2' }) console.log('---', data, ajv.errors) } start()
import Ajv, { ValidateFunction } from 'https://esm.sh/ajv@8.6.1' const schema = { type: 'object', properties: { a: {type: 'string' }, b: { type: 'number' } }, required: ['a'] } const ajv: Ajv = new Ajv() const validate: ValidateFunction = ajv.compile(schema) const start = async (): Promise<any> => { const data: boolean = validate({ a: '1', b: '2' }) console.log('---', data, ajv.errors) } start()