string.d.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { ZodStringDef } from 'zod';
  2. import { ErrorMessages } from "../errorMessages.js";
  3. import { Refs } from "../Refs.js";
  4. /**
  5. * Generated from the regular expressions found here as of 2024-05-22:
  6. * https://github.com/colinhacks/zod/blob/master/src/types.ts.
  7. *
  8. * Expressions with /i flag have been changed accordingly.
  9. */
  10. export declare const zodPatterns: {
  11. /**
  12. * `c` was changed to `[cC]` to replicate /i flag
  13. */
  14. readonly cuid: RegExp;
  15. readonly cuid2: RegExp;
  16. readonly ulid: RegExp;
  17. /**
  18. * `a-z` was added to replicate /i flag
  19. */
  20. readonly email: RegExp;
  21. /**
  22. * Constructed a valid Unicode RegExp
  23. *
  24. * Lazily instantiate since this type of regex isn't supported
  25. * in all envs (e.g. React Native).
  26. *
  27. * See:
  28. * https://github.com/colinhacks/zod/issues/2433
  29. * Fix in Zod:
  30. * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
  31. */
  32. readonly emoji: () => RegExp;
  33. /**
  34. * Unused
  35. */
  36. readonly uuid: RegExp;
  37. /**
  38. * Unused
  39. */
  40. readonly ipv4: RegExp;
  41. /**
  42. * Unused
  43. */
  44. readonly ipv6: RegExp;
  45. readonly base64: RegExp;
  46. readonly nanoid: RegExp;
  47. };
  48. export type JsonSchema7StringType = {
  49. type: 'string';
  50. minLength?: number;
  51. maxLength?: number;
  52. format?: 'email' | 'idn-email' | 'uri' | 'uuid' | 'date-time' | 'ipv4' | 'ipv6' | 'date' | 'time' | 'duration';
  53. pattern?: string;
  54. allOf?: {
  55. pattern: string;
  56. errorMessage?: ErrorMessages<{
  57. pattern: string;
  58. }>;
  59. }[];
  60. anyOf?: {
  61. format: string;
  62. errorMessage?: ErrorMessages<{
  63. format: string;
  64. }>;
  65. }[];
  66. errorMessage?: ErrorMessages<JsonSchema7StringType>;
  67. contentEncoding?: string;
  68. };
  69. export declare function parseStringDef(def: ZodStringDef, refs: Refs): JsonSchema7StringType;
  70. //# sourceMappingURL=string.d.ts.map