@macalinao/zod-solana
Version:
Zod schemas for Solana types with @solana/kit integration
22 lines • 559 B
JavaScript
import { address } from "@solana/kit";
import { z } from "zod";
/**
* A Zod schema for Solana addresses.
* Validates that a string is a valid Solana address and transforms it to an Address type.
* Compatible with both Zod v3 and v4.
*/
export const addressSchema = z
.string()
.transform((val, ctx) => {
try {
return address(val);
}
catch {
ctx.addIssue({
code: "custom",
message: "Invalid Solana address",
});
return z.NEVER;
}
});
//# sourceMappingURL=address-schema.js.map