feat: add handling for draft-04 style for boolean in exclusiveMinimum and exclusiveMaximum#30
Conversation
…veMinimum and exclusiveMaximum
|
Ran tests in ajv and tested this version in CLI. |
| // Only use exclusive operators if the exclusive keyword is a boolean (Draft-04 style) | ||
| // If it's a number, it's an independent constraint (Draft-06+ style) | ||
| const opsIdx = exclusive === true ? 1 : 0 | ||
| return KWDs[limitKeyword].ops[opsIdx] |
There was a problem hiding this comment.
Here we are handling when exclusiveMinimum/exclusiveMaximum is a boolean. If they are provided it will have influence on the minimum/maximum operator. e.g. so here we just getting < or <= based on the exclusiveMinimum/exclusiveMaximum boolean statement
| code(cxt: KeywordCxt) { | ||
| const {data, schemaCode, keyword, schema, parentSchema} = cxt | ||
|
|
||
| if (typeof schema === "boolean") { |
There was a problem hiding this comment.
Here we are checking if exclusiveMinimum/exclusiveMaximum is boolean, if yes to check if pair keyword for it exists. e.g. exclusiveMinimum => minimum, exclusiveMaximum => maximum
| } | ||
|
|
||
| // Draft-06+ style: numeric exclusiveMaximum/exclusiveMinimum | ||
| const failOp = keyword === "exclusiveMaximum" ? ops.GTE : ops.LTE |
There was a problem hiding this comment.
Here we are checking for a draft-06 style if exclusiveMinimum/exclusiveMaximum is a number and get proper operator for it >= or <=
| } | ||
| }, | ||
| "tests": [ | ||
| { |
There was a problem hiding this comment.
Deleted these tests because we didn't add support for exclusiveMinimum/exclusiveMaximum in a runtime. But need more investigation, maybe it will start working after adding property to validate.
|
resolver in #39 |
What issue does this pull request resolve?
Resolves #1610
What changes did you make?
limitNumbers.tsfunctionality to trigger only forminimumandmaximumkeywords. However,kwdOpfunction will check if booleanexclusiveMinimum/exclusiveMaximumexists in parent and return proper validation operation.limitNumberExclusive.tsfile to trigger only whenexclusiveMinimum/exclusiveMaximumprovided.Is there anything that requires more attention while reviewing?