Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade ajv to the latest version 7 release #40

Merged
merged 3 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict'

const Ajv = require('ajv')
const ajv = new Ajv({ allErrors: true, removeAdditional: true, useDefaults: true, coerceTypes: true })

ajv.addKeyword('separator', {
const separator = {
type: 'string',
metaSchema: {
type: 'string',
Expand All @@ -13,9 +10,12 @@ ajv.addKeyword('separator', {
valid: true,
errors: false,
compile: (schema) => (data, dataPath, parentData, parentDataProperty) => {
parentData[parentDataProperty] = data === '' ? [] : data.split(schema)
console.log({ data, dataPath, parentData, parentDataProperty })
if (parentData && parentDataProperty) {
parentData[parentDataProperty] = data === '' ? [] : data.split(schema)
}
}
})
}

const optsSchema = {
type: 'object',
Expand All @@ -34,6 +34,19 @@ const optsSchema = {
expandEnv: { type: ['boolean'], default: false }
}
}

const Ajv = require('ajv').default
nigelhanlon marked this conversation as resolved.
Show resolved Hide resolved
const ajv = new Ajv({
allErrors: true,
removeAdditional: true,
useDefaults: true,
coerceTypes: true,
allowUnionTypes: true,
keywords: {
separator
}
})

const optsSchemaValidator = ajv.compile(optsSchema)

function loadAndValidateEnvironment (_opts) {
Expand Down
Loading