error.js 893 B

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