( schema: S, data: unknown, options?: ParseRequestOptions )
| 282 | } |
| 283 | |
| 284 | function validateRequestSchema<S extends ApiSchema>( |
| 285 | schema: S, |
| 286 | data: unknown, |
| 287 | options?: ParseRequestOptions |
| 288 | ): ValidationResult<S> { |
| 289 | const result = schema.safeParse(data) |
| 290 | if (!result.success) { |
| 291 | return { |
| 292 | success: false, |
| 293 | response: options?.validationErrorResponse |
| 294 | ? options.validationErrorResponse(result.error) |
| 295 | : validationErrorResponse(result.error), |
| 296 | error: result.error, |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | return { success: true, data: result.data } |
| 301 | } |
no test coverage detected