Skip to content

Commit

Permalink
Merge branch 'SoAsEr-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed May 20, 2021
2 parents f54f1b7 + cbb79c6 commit 81a2526
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/vocabularies/validation/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ const def: CodeKeywordDefinition = {
$data: true,
error,
code(cxt: KeywordCxt) {
const {gen, data, schemaCode} = cxt
// TODO optimize for scalar values in schema
cxt.fail$data(_`!${useFunc(gen, equal)}(${data}, ${schemaCode})`)
const {gen, data, $data, schemaCode, schema} = cxt
if ($data || (schema && typeof schema == "object")) {
cxt.fail$data(_`!${useFunc(gen, equal)}(${data}, ${schemaCode})`)
} else {
cxt.fail(_`${schema} !== ${data}`)
}
},
}

Expand Down
2 changes: 1 addition & 1 deletion lib/vocabularies/validation/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const def: CodeKeywordDefinition = {

function equalCode(vSchema: Name, i: number): Code {
const sch = schema[i]
return sch && typeof sch === "object"
return typeof sch === "object" && sch !== null
? _`${eql}(${data}, ${vSchema}[${i}])`
: _`${data} === ${sch}`
}
Expand Down

0 comments on commit 81a2526

Please sign in to comment.