z.js 430 B

123456789101112131415161718
  1. import * as z from "zod"
  2. z.config({
  3. customError: (issue) => {
  4. switch (issue.code) {
  5. case "too_small":
  6. if (issue.origin === "string" && _isEmpty(issue.input)) {
  7. return "Cannot be blank."
  8. } else {
  9. return `Must be at least ${issue.minimum} characters.`
  10. }
  11. case "too_big":
  12. return `Cannot be longer than ${issue.maximum} characters.`
  13. }
  14. }
  15. })
  16. export default z