Skip to content

Commit ae10f38

Browse files
Copilothotlong
andcommitted
Improve type safety: use z.ZodIssue instead of any
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 5ba8437 commit ae10f38

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

packages/protocols/graphql/src/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function validateGraphQLInput<T>(
148148
return schema.parse(input);
149149
} catch (error) {
150150
if (error instanceof z.ZodError) {
151-
const details: ValidationErrorDetails[] = error.issues.map((err: any) => ({
151+
const details: ValidationErrorDetails[] = error.issues.map((err: z.ZodIssue) => ({
152152
field: err.path.join('.'),
153153
message: err.message,
154154
code: err.code

packages/protocols/json-rpc/src/validation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function validateRequest(request: unknown): z.infer<typeof JSONRPCRequest
108108
JSONRPCErrorCode.INVALID_REQUEST,
109109
'Invalid JSON-RPC request format',
110110
{
111-
validationErrors: error.issues.map((err: any) => ({
111+
validationErrors: error.issues.map((err: z.ZodIssue) => ({
112112
path: err.path.join('.'),
113113
message: err.message
114114
}))
@@ -131,7 +131,7 @@ export function validateBatchRequest(request: unknown): z.infer<typeof JSONRPCBa
131131
JSONRPCErrorCode.INVALID_REQUEST,
132132
'Invalid JSON-RPC batch request format',
133133
{
134-
validationErrors: error.issues.map((err: any) => ({
134+
validationErrors: error.issues.map((err: z.ZodIssue) => ({
135135
path: err.path.join('.'),
136136
message: err.message
137137
}))
@@ -188,7 +188,7 @@ export function validateMethodParams<T>(
188188
JSONRPCErrorCode.INVALID_PARAMS,
189189
`Invalid parameters for method '${methodName}'`,
190190
{
191-
validationErrors: error.issues.map((err: any) => ({
191+
validationErrors: error.issues.map((err: z.ZodIssue) => ({
192192
path: err.path.join('.'),
193193
message: err.message
194194
}))

packages/protocols/odata-v4/src/validation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export function validateQueryOptions(options: unknown): z.infer<typeof QueryOpti
223223
ODataErrorCode.INVALID_QUERY,
224224
'Invalid query options',
225225
undefined,
226-
error.issues.map((err: any) => ({
226+
error.issues.map((err: z.ZodIssue) => ({
227227
code: err.code,
228228
message: err.message,
229229
target: err.path.join('.')
@@ -246,7 +246,7 @@ export function validateBatchRequest(request: unknown): z.infer<typeof BatchRequ
246246
ODataErrorCode.BAD_REQUEST,
247247
'Invalid batch request format',
248248
undefined,
249-
error.issues.map((err: any) => ({
249+
error.issues.map((err: z.ZodIssue) => ({
250250
code: err.code,
251251
message: err.message,
252252
target: err.path.join('.')

0 commit comments

Comments
 (0)