You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a validation utility which uses the zod library to parse and validate a Zod schema. When validation errors occur, format the ZodError issues into a nicely formatted ValidationError.
Acceptance criteria
GIVEN an object is validated with the validation utility
WHEN the validation succeeds
THEN the parsed and validated object is returned
WHEN the validation fails
THEN a ValidationError is returned whose message contains the issues from the original ZodError
After researching a plain "validation" utility, I determined that Zod already makes schema validation so simple that there is no value added by creating a validation utility for Zod.
However, there is some value to be gained by creating a Lambda configuration validation utility. The configuration utility will:
Validate environment variables with a zod schema sourced from process.env
Cache a singleton of the parsed, transformed, and validated configuration object.
Provide a "getter" to fetch the config object
Provide a "refresh" helper function to revalidate and recreate the singleton config object which is useful for testing of different configuration variable values
Activity
mwarman commentedon Dec 20, 2025
After researching a plain "validation" utility, I determined that Zod already makes schema validation so simple that there is no value added by creating a validation utility for Zod.
However, there is some value to be gained by creating a Lambda configuration validation utility. The configuration utility will:
process.env[-]Validation utility[/-][+]Configuration utility[/+]