type coercion
Converting a value from one type to another, such as the text "8080" into the number 8080.
In more detail
Environment variables are always text, so a port number has to be coerced into a real number while being validated. Without coercion, "8080" + 1 would give "80801" instead of 8081.
Related terms
- Zod — A TypeScript library for declaring validation schemas that check data at run time and also produce matching static types.
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
Taught in
- Environment Configuration: Secrets & Multi-Stage — Production Full-Stack Engineering