UNPKG

@react-form-builder/core

Version:

React JSON Schema Form Builder to create complex, validated, reusable forms with no deep React knowledge required

18 lines (17 loc) 1.09 kB
import { ruleBuilder as e } from "../utils/ruleBuilder.js"; import { zodErrorParams as m, errorForUndefined as l } from "./consts.js"; import * as i from "zod/mini"; import { toRuleValidator as a, numberScheme as o } from "./zodRuleBuilders.js"; const n = { required: e().withValidatorFactory(() => a(o)), min: e().withParameter("limit", "number", !0).withValidatorFactory(({ limit: r, message: t }) => a(o, i.gte(r, m(t)))), max: e().withParameter("limit", "number", !0).withValidatorFactory(({ limit: r, message: t }) => a(o, i.lte(r, m(t)))), lessThan: e().withParameter("value", "number", !0).withValidatorFactory(({ value: r, message: t }) => a(o, i.lt(r, m(t)))), moreThan: e().withParameter("value", "number", !0).withValidatorFactory(({ message: r, value: t }) => a(o, i.gt(t, m(r)))), integer: e().withValidatorFactory(() => a(i.int({ error: l }))), multipleOf: e().withParameter("value", "number", !0).withValidatorFactory(({ message: r, value: t }) => a(o, i.multipleOf(t, m(r)))) }; export { n as ZodNumberRules }; //# sourceMappingURL=ZodNumberRules.js.map