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

Set strictSchema by default to make silent errors less likely. #674

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions lib/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const clone = require('rfdc')({ proto: true })
class Validator {
constructor (ajvOptions) {
this.ajv = new Ajv({
...ajvOptions,
strictSchema: false,
strictSchema: true,
validateSchema: false,
allowUnionTypes: true,
uriResolver: fastUri
uriResolver: fastUri,
...ajvOptions
})

ajvFormats(this.ajv)
Expand Down
2 changes: 1 addition & 1 deletion test/anyof.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ test('symbol value in schema', (t) => {
required: ['value']
}

const stringify = build(schema)
const stringify = build(schema, { ajv: { strictSchema: false } })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because strictSchema is via this PR set to true by default...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But is that needed for that test to pass?

t.equal(stringify({ value: 'foo' }), '{"value":"foo"}')
t.equal(stringify({ value: 'bar' }), '{"value":"bar"}')
t.equal(stringify({ value: 'baz' }), '{"value":"baz"}')
Expand Down
2 changes: 1 addition & 1 deletion test/array.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ test('object array with anyOf and symbol', (t) => {
required: ['name', 'option']
}
}
const stringify = build(schema)
const stringify = build(schema, { ajv: { strictSchema: false } })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this?

const value = stringify([
{ name: 'name-0', option: 'Foo' },
{ name: 'name-1', option: 'Bar' }
Expand Down