Last change
on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
859 bytes
|
Line | |
---|
1 | import type {CodeKeywordDefinition, ErrorNoParams, AnySchema} from "../../types"
|
---|
2 | import type {KeywordCxt} from "../../compile/validate"
|
---|
3 | import {alwaysValidSchema} from "../../compile/util"
|
---|
4 |
|
---|
5 | export type NotKeywordError = ErrorNoParams<"not", AnySchema>
|
---|
6 |
|
---|
7 | const def: CodeKeywordDefinition = {
|
---|
8 | keyword: "not",
|
---|
9 | schemaType: ["object", "boolean"],
|
---|
10 | trackErrors: true,
|
---|
11 | code(cxt: KeywordCxt) {
|
---|
12 | const {gen, schema, it} = cxt
|
---|
13 | if (alwaysValidSchema(it, schema)) {
|
---|
14 | cxt.fail()
|
---|
15 | return
|
---|
16 | }
|
---|
17 |
|
---|
18 | const valid = gen.name("valid")
|
---|
19 | cxt.subschema(
|
---|
20 | {
|
---|
21 | keyword: "not",
|
---|
22 | compositeRule: true,
|
---|
23 | createErrors: false,
|
---|
24 | allErrors: false,
|
---|
25 | },
|
---|
26 | valid
|
---|
27 | )
|
---|
28 |
|
---|
29 | cxt.failResult(
|
---|
30 | valid,
|
---|
31 | () => cxt.reset(),
|
---|
32 | () => cxt.error()
|
---|
33 | )
|
---|
34 | },
|
---|
35 | error: {message: "must NOT be valid"},
|
---|
36 | }
|
---|
37 |
|
---|
38 | export default def
|
---|
Note:
See
TracBrowser
for help on using the repository browser.