added validation for character limit, user can't add more than 200 character for description

This commit is contained in:
Pramod Mahajan 2025-04-18 23:23:10 +05:30
parent 7308bd8d03
commit 868f5038b0

View File

@ -12,7 +12,7 @@ import {checkIfCurrentDate} from "../../utils/dateUtils";
const schema = z.object({
markTime: z.string().nonempty({message:"Time is required"}),
description:z.string().optional()
description:z.string().max(200,"description should less than 200 chracters").optional()
});
const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
@ -30,6 +30,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
setValue,
} = useForm({
resolver: zodResolver( schema ),
mode:"onChange"
});
const onSubmit = ( data ) =>
@ -85,6 +86,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
name="description"
className="form-control"
{...register( "description" )}
maxLength={200}
/>
{errors.description && (
<p className="text-danger">{errors.description.message}</p>