import {
  castNumber
} from "./chunk-SMQT3ZNO.js";

// src/lib/validation.ts
import i18next from "i18next";
import { z } from "zod";
var optionalInt = z.union([z.string(), z.number()]).optional().refine(
  (value) => {
    if (value === "" || value === void 0) {
      return true;
    }
    return Number.isInteger(castNumber(value));
  },
  {
    message: i18next.t("validation.mustBeInt")
  }
).refine(
  (value) => {
    if (value === "" || value === void 0) {
      return true;
    }
    return castNumber(value) >= 0;
  },
  {
    message: i18next.t("validation.mustBePositive")
  }
);
var optionalFloat = z.union([z.string(), z.number()]).optional().refine(
  (value) => {
    if (value === "" || value === void 0) {
      return true;
    }
    return castNumber(value) >= 0;
  },
  {
    message: i18next.t("validation.mustBePositive")
  }
);
var metadataFormSchema = z.array(
  z.object({
    key: z.string(),
    value: z.unknown(),
    isInitial: z.boolean().optional(),
    isDeleted: z.boolean().optional(),
    isIgnored: z.boolean().optional()
  })
);

export {
  optionalInt
};
