Skip to content

Commit

Permalink
refactor: better errors on getAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabadesso committed Feb 24, 2025
1 parent 4542861 commit 727404e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/hathor-rpc-handler/src/rpcMethods/getAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ const getAddressSchema = z.object({
...data,
fullPath: data.full_path,
})).refine(
(data) => {
if (data.type === 'index') {
return data.index !== undefined;
}
if (data.type === 'full_path') {
return data.fullPath !== undefined;
}
return true;
},
(data) => data.type !== 'index' || data.index !== undefined,
{
message: "index is required when type is 'index'",
}
).refine(
(data) => data.type !== 'full_path' || data.fullPath !== undefined,
{
message: "index is required when type is 'index', full_path is required when type is 'full_path'",
message: "full_path is required when type is 'full_path'",
}
);

Expand Down

0 comments on commit 727404e

Please sign in to comment.