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,}) => {
|
||||||
@ -30,6 +30,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
|||||||
setValue,
|
setValue,
|
||||||
} = useForm({
|
} = useForm({
|
||||||
resolver: zodResolver( schema ),
|
resolver: zodResolver( schema ),
|
||||||
|
mode:"onChange"
|
||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = ( data ) =>
|
const onSubmit = ( data ) =>
|
||||||
@ -85,6 +86,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
|||||||
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