UNPKG

893 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.typeErrorParams = exports.typeErrorMessage = exports.typeError = void 0;
4const codegen_1 = require("../../compile/codegen");
5function typeError(t) {
6 return {
7 message: (cxt) => typeErrorMessage(cxt, t),
8 params: (cxt) => typeErrorParams(cxt, t),
9 };
10}
11exports.typeError = typeError;
12function typeErrorMessage({ parentSchema }, t) {
13 return (parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.nullable) ? `must be ${t} or null` : `must be ${t}`;
14}
15exports.typeErrorMessage = typeErrorMessage;
16function typeErrorParams({ parentSchema }, t) {
17 return (0, codegen_1._) `{type: ${t}, nullable: ${!!(parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.nullable)}}`;
18}
19exports.typeErrorParams = typeErrorParams;
20//# sourceMappingURL=error.js.map
\No newline at end of file