UNPKG

@nucypher/taco

Version:

### [`nucypher/taco-web`](../../README.md)

40 lines 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ifThenElseConditionSchema = exports.IfThenElseConditionType = void 0; const zod_1 = require("zod"); const multi_condition_1 = require("../multi-condition"); const common_1 = require("./common"); const utils_1 = require("./utils"); exports.IfThenElseConditionType = 'if-then-else'; exports.ifThenElseConditionSchema = zod_1.z.lazy(() => common_1.baseConditionSchema .extend({ conditionType: zod_1.z .literal(exports.IfThenElseConditionType) .default(exports.IfThenElseConditionType), ifCondition: utils_1.anyConditionSchema, thenCondition: utils_1.anyConditionSchema, elseCondition: zod_1.z.union([utils_1.anyConditionSchema, zod_1.z.boolean()]), }) .refine( // already at 2nd level since checking member condition (condition) => (0, multi_condition_1.maxNestedDepth)(2)(condition.ifCondition, 2), { message: 'Exceeded max nested depth of 2 for multi-condition type', path: ['ifCondition'], }) .refine( // already at 2nd level since checking member condition (condition) => (0, multi_condition_1.maxNestedDepth)(2)(condition.thenCondition, 2), { message: 'Exceeded max nested depth of 2 for multi-condition type', path: ['thenCondition'], }) .refine((condition) => { if (typeof condition.elseCondition !== 'boolean') { // already at 2nd level since checking member condition return (0, multi_condition_1.maxNestedDepth)(2)(condition.elseCondition, 2); } return true; }, { message: 'Exceeded max nested depth of 2 for multi-condition type', path: ['elseCondition'], })); //# sourceMappingURL=if-then-else.js.map