-
Notifications
You must be signed in to change notification settings - Fork 162
Open
Labels
discussingThe issue needs to be discussed, elaborated, or refinedThe issue needs to be discussed, elaborated, or refinedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityneed-customer-feedbackRequires more customers feedback before making or revisiting a decisionRequires more customers feedback before making or revisiting a decisionparserThis item relates to the Parser UtilityThis item relates to the Parser Utility
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
discussingThe issue needs to be discussed, elaborated, or refinedThe issue needs to be discussed, elaborated, or refinedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityneed-customer-feedbackRequires more customers feedback before making or revisiting a decisionRequires more customers feedback before making or revisiting a decisionparserThis item relates to the Parser UtilityThis item relates to the Parser Utility
Type
Projects
Status
Ideas