added validation for character limit, user can't add more than 200 character for description
This commit is contained in:
parent
7308bd8d03
commit
868f5038b0
@ -12,7 +12,7 @@ import {checkIfCurrentDate} from "../../utils/dateUtils";
|
|||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
markTime: z.string().nonempty({message:"Time is required"}),
|
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,}) => {
|
const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
||||||
@ -29,7 +29,8 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
|||||||
reset,
|
reset,
|
||||||
setValue,
|
setValue,
|
||||||
} = useForm({
|
} = useForm({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver( schema ),
|
||||||
|
mode:"onChange"
|
||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = ( data ) =>
|
const onSubmit = ( data ) =>
|
||||||
@ -84,7 +85,8 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
|||||||
rows="3"
|
rows="3"
|
||||||
name="description"
|
name="description"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
{...register("description")}
|
{...register( "description" )}
|
||||||
|
maxLength={200}
|
||||||
/>
|
/>
|
||||||
{errors.description && (
|
{errors.description && (
|
||||||
<p className="text-danger">{errors.description.message}</p>
|
<p className="text-danger">{errors.description.message}</p>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user