1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
|
4 | const errors_1 = require("../errors");
|
5 | const codegen_1 = require("../codegen");
|
6 | const names_1 = require("../names");
|
7 | const boolError = {
|
8 | message: "boolean schema is false",
|
9 | };
|
10 | function topBoolOrEmptySchema(it) {
|
11 | const { gen, schema, validateName } = it;
|
12 | if (schema === false) {
|
13 | falseSchemaError(it, false);
|
14 | }
|
15 | else if (typeof schema == "object" && schema.$async === true) {
|
16 | gen.return(names_1.default.data);
|
17 | }
|
18 | else {
|
19 | gen.assign((0, codegen_1._) `${validateName}.errors`, null);
|
20 | gen.return(true);
|
21 | }
|
22 | }
|
23 | exports.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
24 | function boolOrEmptySchema(it, valid) {
|
25 | const { gen, schema } = it;
|
26 | if (schema === false) {
|
27 | gen.var(valid, false);
|
28 | falseSchemaError(it);
|
29 | }
|
30 | else {
|
31 | gen.var(valid, true);
|
32 | }
|
33 | }
|
34 | exports.boolOrEmptySchema = boolOrEmptySchema;
|
35 | function falseSchemaError(it, overrideAllErrors) {
|
36 | const { gen, data } = it;
|
37 |
|
38 | const cxt = {
|
39 | gen,
|
40 | keyword: "false schema",
|
41 | data,
|
42 | schema: false,
|
43 | schemaCode: false,
|
44 | schemaValue: false,
|
45 | params: {},
|
46 | it,
|
47 | };
|
48 | (0, errors_1.reportError)(cxt, boolError, undefined, overrideAllErrors);
|
49 | }
|
50 |
|
\ | No newline at end of file |