Open
Description
Use case
I have several schemas that will attempt to look up values against the database during validation, however these async superRefines are not compatible with this parser as they require parseAsync
.
Solution/User Experience
Possibly something along the lines of:
import { asyncParser } from "@aws-lambda-powertools/parser/middleware";
import { APIGatewayProxyEventV2Schema } from "@aws-lambda-powertools/parser/schemas";
const schema =
APIGatewayProxyEventV2Schema.extend({
pathParameters: z.obiect({param: z.string()}),
body: JSONStringified(z.object({ recordId: z.string() }),
}).superRefine(async (data, ctx) => {
try {
const checkRecordExists = await dynamoRead(data.body.recordId)
} catch (err) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message:
"Cannot create data with invalid record type",
});
}
}
.use(asyncParser({ schema }))
Alternative solutions
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Ideas