-
-
Notifications
You must be signed in to change notification settings - Fork 883
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix JTD discriminator with more than 8 properties, fixes #1971 * prettier
- Loading branch information
1 parent
527d43a
commit c5c195b
Showing
2 changed files
with
74 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import _Ajv from "../ajv_jtd" | ||
import * as assert from "assert" | ||
|
||
describe("JTD discriminator with more than 8 (hardcoded in properties.ts) properties (issue #1971)", () => { | ||
const ajv = new _Ajv() | ||
|
||
it("should correctly validate empty values form", () => { | ||
const schema = { | ||
discriminator: "tag", | ||
mapping: { | ||
manual: { | ||
properties: { | ||
first: {type: "uint16"}, | ||
second: {type: "uint16"}, | ||
third: {type: "uint16"}, | ||
fourth: {type: "uint16"}, | ||
fifth: {type: "uint16"}, | ||
sixth: {type: "uint16"}, | ||
additionalOne: {type: "uint16"}, | ||
additionalTwo: {type: "uint16"}, | ||
}, | ||
}, | ||
auto: { | ||
properties: { | ||
first: {type: "uint16"}, | ||
second: {type: "uint16"}, | ||
third: {type: "uint16"}, | ||
fourth: {type: "uint16"}, | ||
fifth: {type: "uint16"}, | ||
sixth: {type: "uint16"}, | ||
additionalThree: {type: "uint16"}, | ||
}, | ||
}, | ||
}, | ||
} | ||
const data1 = { | ||
tag: "manual", | ||
first: 1, | ||
second: 1, | ||
third: 1, | ||
fourth: 1, | ||
fifth: 1, | ||
sixth: 1, | ||
additionalOne: 1, | ||
additionalTwo: 1, | ||
} | ||
const data2 = { | ||
tag: "auto", | ||
first: 1, | ||
second: 1, | ||
third: 1, | ||
fourth: 1, | ||
fifth: 1, | ||
sixth: 1, | ||
additionalThree: 1, | ||
} | ||
const validate = ajv.compile(schema) | ||
assert.strictEqual(validate(data1), true) | ||
assert.strictEqual(validate(data2), true) | ||
}) | ||
}) |
c5c195b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O