UNPKG

@tsed/config

Version:
16 lines (15 loc) 461 B
import { AjvService } from "@tsed/ajv"; import { inject } from "@tsed/di"; export async function validate(configName, config, validationSchema) { const ajv = inject(AjvService); try { return await ajv.validate(config, { returnsCoercedValues: true, schema: validationSchema.toJSON() }); } catch (er) { er.message = er.message.replace("Value.", `extends[${configName}].`); throw er; } }