NestJS · Middle · Question 49 of 75
How do you validate environment variables at startup with @nestjs/config?
- ✓Correct answer: Pass a
validationSchema(Joi) or avalidatefunction (e.g. with class-validator or Zod) toConfigModule.forRoot() - 2Check them in every service
- 3Nest validates them automatically
Explanation
Failing fast at startup is better than crashing on the first request that needs a missing variable.