source: trip-planner-front/node_modules/ajv/lib/vocabularies/applicator/not.ts@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 859 bytes
Line 
1import type {CodeKeywordDefinition, ErrorNoParams, AnySchema} from "../../types"
2import type {KeywordCxt} from "../../compile/validate"
3import {alwaysValidSchema} from "../../compile/util"
4
5export type NotKeywordError = ErrorNoParams<"not", AnySchema>
6
7const 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
38export default def
Note: See TracBrowser for help on using the repository browser.