Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
CptSchnitz committed Sep 8, 2024
1 parent 3d04ca0 commit 86bf9b8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/validator.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
import Ajv, { SchemaObject } from 'ajv';
import { readFileSync } from 'node:fs';
import Ajv, { AnySchemaObject, SchemaObject } from 'ajv/dist/2019';
import addFormats from 'ajv-formats';
import lodash from 'lodash';
import { ValidationError, betterAjvErrors } from '@apideck/better-ajv-errors';
import { createDebug } from './utils/debug';

const debug = createDebug('validator');

export const ajvConfigValidator = addFormats(
const draft7MetaSchema = JSON.parse(
readFileSync(require.resolve('ajv/dist/refs/json-schema-draft-07.json'), { encoding: 'utf-8' })
) as AnySchemaObject;

const ajvConfigValidator = addFormats(
new Ajv({
useDefaults: true,
allErrors: true,
verbose: true,
discriminator: true,
keywords: ['x-env-value'],
}),
['date-time', 'time', 'date', 'email', 'hostname', 'ipv4', 'ipv6', 'uri', 'uuid', 'regex', 'uri-template']
})
);

ajvConfigValidator.addMetaSchema(draft7MetaSchema, 'http://json-schema.org/draft-07/schema#');

export { ajvConfigValidator };

export const ajvOptionsValidator = new Ajv({
useDefaults: true,
coerceTypes: true,
Expand Down

0 comments on commit 86bf9b8

Please sign in to comment.