MCPcopy
hub / github.com/ajv-validator/ajv / testMultipleRangeKeyword

Function testMultipleRangeKeyword

spec/keyword.spec.ts:981–1006  ·  view source on GitHub ↗
(definition, numErrors?: number)

Source from the content-addressed store, hash-verified

979 }
980
981 function testMultipleRangeKeyword(definition, numErrors?: number) {
982 instances.forEach((_ajv) => {
983 _ajv.opts.strictTypes = false
984 _ajv.addKeyword(definition)
985 _ajv.addKeyword({keyword: "exclusiveRange", schemaType: "boolean"})
986
987 const schema = {
988 properties: {
989 a: {type: "number", "x-range": [2, 4], exclusiveRange: true},
990 b: {type: "number", "x-range": [2, 4], exclusiveRange: false},
991 },
992 additionalProperties: {type: "number", "x-range": [5, 7]},
993 items: {type: "number", "x-range": [5, 7]},
994 }
995 const validate = _ajv.compile(schema)
996
997 shouldBeValid(validate, {a: 3.99, b: 4})
998 shouldBeInvalid(validate, {a: 4, b: 4}, numErrors)
999
1000 shouldBeValid(validate, {a: 2.01, c: 7})
1001 shouldBeInvalid(validate, {a: 2.01, c: 7.01}, numErrors)
1002
1003 shouldBeValid(validate, [5, 6, 7])
1004 shouldBeInvalid(validate, [7.01], numErrors)
1005 })
1006 }
1007
1008 function shouldBeRangeError(
1009 error,

Callers 1

keyword.spec.tsFile · 0.85

Calls 4

shouldBeValidFunction · 0.70
shouldBeInvalidFunction · 0.70
addKeywordMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…