UNPKG

@jirutka/ajv-cli

Version:

CLI for Ajv JSON Schema Validator with human-friendly error messages

61 lines 1.73 kB
import { AnyOf, Bool, Const, Enum, Uint, } from '../args-parser.js'; export const schemaSpecs = ['jtd', 'draft7', 'draft2019', 'draft2020']; const ajvOptionsSchema = { // Ajv strict mode options allowMatchingProperties: Bool, allowUnionTypes: Bool, strict: AnyOf(Bool, Const('log')), strictNumbers: AnyOf(Bool, Const('log')), strictRequired: AnyOf(Bool, Const('log')), strictSchema: AnyOf(Bool, Const('log')), strictTuples: AnyOf(Bool, Const('log')), strictTypes: AnyOf(Bool, Const('log')), validateFormats: Bool, // Ajv validation and reporting options allErrors: Bool, comment: Bool, data: Bool, verbose: Bool, // Ajv options to modify validated data coerceTypes: AnyOf(Bool, Const('array')), removeAdditional: AnyOf(Bool, Enum('all', 'failing')), useDefaults: AnyOf(Bool, Const('empty')), // Ajv advanced options codeEs5: Bool, codeEsm: Bool, codeFormats: String, codeLines: Bool, codeOptimize: AnyOf(Bool, Uint), inlineRefs: AnyOf(Bool, Uint), loopEnum: Uint, loopRequired: Uint, messages: Bool, multipleOfPrecision: AnyOf(Bool, Uint), ownProperties: Bool, }; export const ajvOptionNames = new Set(Object.keys(ajvOptionsSchema)); export const commonOptionsSchema = { keywords: { type: [String], alias: 'c', }, metaSchema: { type: [String], alias: 'm', }, refSchema: { type: [String], alias: 'r', }, schema: { required: true, type: [String], alias: 's', default: () => [], }, spec: { type: Enum(...schemaSpecs), }, ...ajvOptionsSchema, }; //# sourceMappingURL=common.js.map