Change Milestone Flag

The ideal schema for this endpoint.

Schema

This validates an escrow form using Zod, including wallet addresses, change flag properties and milestone index.

import { isValidWallet } from "@/helpers/valid-data.helper";
import { z } from "zod";

export const formSchema = z.object({
  contractId: z.string().min(1, "Contract ID is required"),
  milestoneIndex: z.string().min(1, "Milestone index is required"),
  newFlag: z.boolean(),
  approver: z
    .string()
    .min(1, {
      message: "Approver is required.",
    })
    .refine((value) => isValidWallet(value), {
      message: "Approver must be a valid wallet.",
    }),
});

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.

Last updated

Was this helpful?