array.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.parseArrayDef = void 0;
  4. const zod_1 = require("zod");
  5. const errorMessages_1 = require("../errorMessages.js");
  6. const parseDef_1 = require("../parseDef.js");
  7. function parseArrayDef(def, refs) {
  8. const res = {
  9. type: 'array',
  10. };
  11. if (def.type?._def?.typeName !== zod_1.ZodFirstPartyTypeKind.ZodAny) {
  12. res.items = (0, parseDef_1.parseDef)(def.type._def, {
  13. ...refs,
  14. currentPath: [...refs.currentPath, 'items'],
  15. });
  16. }
  17. if (def.minLength) {
  18. (0, errorMessages_1.setResponseValueAndErrors)(res, 'minItems', def.minLength.value, def.minLength.message, refs);
  19. }
  20. if (def.maxLength) {
  21. (0, errorMessages_1.setResponseValueAndErrors)(res, 'maxItems', def.maxLength.value, def.maxLength.message, refs);
  22. }
  23. if (def.exactLength) {
  24. (0, errorMessages_1.setResponseValueAndErrors)(res, 'minItems', def.exactLength.value, def.exactLength.message, refs);
  25. (0, errorMessages_1.setResponseValueAndErrors)(res, 'maxItems', def.exactLength.value, def.exactLength.message, refs);
  26. }
  27. return res;
  28. }
  29. exports.parseArrayDef = parseArrayDef;
  30. //# sourceMappingURL=array.js.map