the data to parse
optional envelope to use when parsing the data
the schema to use
Optional
safeParse: falsewhether to throw on error, if true
it will return a ParsedResult
with the original event if the parsing fails
import { z } from 'zod';
import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
import { parse } from '@aws-lambda-powertools/parser';
const Order = z.object({
orderId: z.string(),
description: z.string(),
});
const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
const parsedEvent = parse(event, SqsEnvelope, Order);
}
Parse the data using the provided schema and optional envelope.
the data to parse
optional envelope to use when parsing the data
the schema to use
whether to throw on error, if true
it will return a ParsedResult
with the original event if the parsing fails
import { z } from 'zod';
import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
import { parse } from '@aws-lambda-powertools/parser';
const Order = z.object({
orderId: z.string(),
description: z.string(),
});
const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
const parsedEvent = parse(event, SqsEnvelope, Order);
}
Parse the data using the provided schema and optional envelope.
the data to parse
optional envelope to use when parsing the data
the schema to use
whether to throw on error, if true
it will return a ParsedResult
with the original event if the parsing fails
import { z } from 'zod';
import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
import { parse } from '@aws-lambda-powertools/parser';
const Order = z.object({
orderId: z.string(),
description: z.string(),
});
const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
const parsedEvent = parse(event, SqsEnvelope, Order);
}
Parse the data using the provided schema and optional envelope.
import { z } from 'zod';
import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
import { parse } from '@aws-lambda-powertools/parser';
const Order = z.object({
orderId: z.string(),
description: z.string(),
});
const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
const parsedEvent = parse(event, SqsEnvelope, Order);
}
Parse the data using the provided schema and optional envelope.
import { z } from 'zod';
import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
import { parse } from '@aws-lambda-powertools/parser';
const Order = z.object({
orderId: z.string(),
description: z.string(),
});
const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
const parsedEvent = parse(event, SqsEnvelope, Order);
}
Parse the data using the provided schema and optional envelope.
the data to parse
optional envelope to use when parsing the data
the schema to use
Optional
safeParse: booleanwhether to throw on error, if true
it will return a ParsedResult
with the original event if the parsing fails
import { z } from 'zod';
import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
import { parse } from '@aws-lambda-powertools/parser';
const Order = z.object({
orderId: z.string(),
description: z.string(),
});
const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
const parsedEvent = parse(event, SqsEnvelope, Order);
}
Parse the data using the provided schema and optional envelope.
import { z } from 'zod';
import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
import { parse } from '@aws-lambda-powertools/parser';
const Order = z.object({
orderId: z.string(),
description: z.string(),
});
const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
const parsedEvent = parse(event, SqsEnvelope, Order);
}
Parse the data using the provided schema and optional envelope.