Frameworks and SDKs
NestJS email validation integration
A NestJS module that checks the email address of a request before your route’s handler runs. It refuses addresses that cannot receive email and throwaway inboxes, hands the result to your handler, and lets the request go on when the API cannot answer in time.
Read the full setup guideGet an API key
- Setup guide
- An npm package file for your NestJS app
@Post('signup')
@ValidateEmail()
signup(@EmailOutcome() outcome: EmailValidationOutcome) {
return { created: true, status: outcome.result?.status ?? null };
}At a glance.
- Status
- Setup guide. Not listed on a marketplace yet: you set it up yourself in a few steps, below and in the full guide.
- For
- NestJS developers with sign-up, invite or contact routes who want the addresses that will bounce refused before an account is created, without a second call in the handler.
- You need
- NestJS 12 or 11 on its Express platform, Node.js 22.12 or newer, the package file from the guide, and an API key made for it, with a daily credit cap, set in your environment as
EV_API_KEY. - Costs
- 1 credit = 1 validated address, as with any API request. Free: unknown results, API errors, malformed addresses, test addresses on sandbox.email-validation.org, addresses on reserved domains such as example.com and, in a bulk list, repeats of an address (charged once).
- Full guide
- Read the full setup guide
Typical uses.
A guard on your routes
@ValidateEmail() on a route or a controller refuses a request whose address you chose to stop, and @EmailOutcome() hands the result to the handler.
Middleware
EmailValidationMiddleware checks the routes you give it in a module’s configure(); with the guard on the same route and no options of its own there, the address is checked once.
The service in your own code
Inject EmailValidationService and call check(email), for example after a file-upload form is parsed, and refuse the way the guard does.
Set it up. 5 steps.
The short version of the full setup guide, which stays the reference when a step does not match what you see.
Download the package
The package is not on npm yet: download the file from the guide into your app, and commit it if you want it in your dependencies.
Install it
Run
npm installwith the file’s path. It needs nothing besides NestJS itself.Import the module
Add
EmailValidationModule.forRoot()with your key to your app module, orforRootAsync()with@nestjs/config.Guard a route
Put
@ValidateEmail()on your sign-up route.Try it
Post
disposable@sandbox.email-validation.org, which gets a 422 answer, andaccepted@sandbox.email-validation.org, which reaches your handler. Test addresses cost nothing. On a route that mails the address, try only the one that is refused.
Good to know.
invalidanddisposableare refused by default; choose your own list withstopStatuses, for the whole app or one route.catch_allandunknownpass unless you list them.When the API cannot answer (a timeout, a network error, a rate limit, an empty balance), the request goes on and the handler can see why in
notChecked. SetfailOpen: falseto answer 503 instead.The address and the key are never logged; NestJS’s logger gets only our error code and request id.
For EU data residency, set
baseUrltohttps://api-eu.email-validation.org: the same key works on both.
Connect NestJS.
Test it on our sandbox addresses for free, then on your own contacts.
Updated · Maintained by: Email Validation LLC