Open
Description
How should 'validation' specs be implemented, ala CAIP-3, CAIP-22, CAIP-29?
Proposal
I'm imagining that we introduce more specific *Param
types, plus a functional validation function that looks something like:
export interface CAIP3ChainIdParams extends ChainIDParams {
namespace: "eip155",
}
export const isCAIP3ChainId = (params: ChainIdParams): params is CAIP3ChainIdParams => {
if (params.namespace !== "eip155") return false;
try {
// must parse as decimal number
parseInt(params.reference, 10);
} catch {
return false;
}
return true;
};
we could bring in a more extensible validation library like ajv
, or write our own based on some spec we define (a ValidatorSpec
?), but imo may not be worth it unless validation logic gets out of hand.
Metadata
Metadata
Assignees
Labels
No labels