@macalinao/zod-solana
Version:
Zod schemas for Solana types with @solana/kit integration
23 lines (22 loc) • 555 B
JavaScript
import { address } from "@solana/kit";
import * as z from "zod";
//#region src/address-schema.ts
/**
* 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.
*/
const addressSchema = z.string().transform((val, ctx) => {
try {
return address(val);
} catch {
ctx.addIssue({
code: "custom",
message: "Invalid Solana address"
});
return z.NEVER;
}
});
//#endregion
export { addressSchema };
//# sourceMappingURL=address-schema.js.map