diff --git a/frontend/src/components/share/modals/showCreateReverseShareModal.tsx b/frontend/src/components/share/modals/showCreateReverseShareModal.tsx index 4cd40c7e..79ecdd6d 100644 --- a/frontend/src/components/share/modals/showCreateReverseShareModal.tsx +++ b/frontend/src/components/share/modals/showCreateReverseShareModal.tsx @@ -9,11 +9,13 @@ import { Switch, Text, } from "@mantine/core"; -import { useForm } from "@mantine/form"; +import { useForm, yupResolver } from "@mantine/form"; import { useModals } from "@mantine/modals"; import { ModalsContextProps } from "@mantine/modals/lib/context"; +import { getCookie, setCookie } from "cookies-next"; import moment from "moment"; import { FormattedMessage } from "react-intl"; +import * as yup from "yup"; import useTranslate, { translateOutsideContext, } from "../../../hooks/useTranslate.hook"; @@ -22,7 +24,6 @@ import { getExpirationPreview } from "../../../utils/date.util"; import toast from "../../../utils/toast.util"; import FileSizeInput from "../FileSizeInput"; import showCompletedReverseShareModal from "./showCompletedReverseShareModal"; -import { getCookie, setCookie } from "cookies-next"; const showCreateReverseShareModal = ( modals: ModalsContextProps, @@ -65,6 +66,16 @@ const Body = ({ simplified: !!(getCookie("reverse-share.simplified") ?? false), publicAccess: !!(getCookie("reverse-share.public-access") ?? true), }, + validate: yupResolver( + yup.object().shape({ + maxUseCount: yup + .number() + .typeError(t("common.error.invalid-number")) + .min(1, t("common.error.number-too-small", { min: 1 })) + .max(1000, t("common.error.number-too-large", { max: 1000 })) + .required(t("common.error.field-required")), + }), + ), }); const onSubmit = form.onSubmit(async (values) => { diff --git a/frontend/src/i18n/translations/en-US.ts b/frontend/src/i18n/translations/en-US.ts index 94dc4715..1948819b 100644 --- a/frontend/src/i18n/translations/en-US.ts +++ b/frontend/src/i18n/translations/en-US.ts @@ -649,6 +649,8 @@ export default { "common.error.invalid-email": "Invalid email address", "common.error.too-short": "Must be at least {length} characters", "common.error.too-long": "Must be at most {length} characters", + "common.error.number-too-small": "Must be at least {min}", + "common.error.number-too-large": "Must be at most {max}", "common.error.exact-length": "Must be exactly {length} characters", "common.error.invalid-number": "Must be a number", "common.error.field-required": "This field is required",