API Reference
    Preparing search index...
    • A helper function to decode a Base64 string and validate it against a schema.

      Use it for built-in schemas like KinesisDataStreamRecordPayload that have fields that are base64 encoded and extend them with your custom schema.

      For example, if you have an event with a base64 encoded body similar to the following:

      {
      // ... other fields
      "data": "e3Rlc3Q6ICJ0ZXN0In0=",
      }

      You can extend any built-in schema with your custom schema using the Base64Encoded helper function.

      Type Parameters

      • T extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

      Parameters

      • schema: T

        The schema to validate the Base 64 decoded value against

      Returns ZodPipe<ZodPipe<ZodString, ZodTransform<any, string>>, T>

      import { Base64Encoded } from '@aws-lambda-powertools/parser/helpers';
      import { KinesisDataStreamRecordPayload } from '@aws-lambda-powertools/parser/schemas/kinesis';
      import { z } from 'zod';

      const extendedSchema = KinesisDataStreamRecordPayload.extend({
      data: Base64Encoded(z.object({
      test: z.string(),
      }))
      });
      type _ExtendedKinesisDataStream = z.infer<typeof extendedSchema>;