This validates an escrow form using Zod, including wallet addresses.
import{isValidWallet}from"@/helpers/valid-data.helper";import{z}from"zod";exportconstformSchema=z.object({contractId:z.string().min(1,"Contract ID is required"),releaseSigner:z.string().min(1,{message:"Release signer is required.",}).refine((value)=>isValidWallet(value),{message:"Release signer must be a valid wallet.",}),signer:z.string().min(1,"Signer address is required"),});
Custom Hook
This contains all the form logic, including schema validation, onSubmit function and others states and functionalities.
Form
This form is built with react hook form. We use the custom hook and zod schema mentioned before.