DEV Community

Cover image for Out-Of-The-Box DTO Validator
Richard Zampieri for ExpressoTS

Posted on

3 2 1 1 1

Out-Of-The-Box DTO Validator

πŸ‘‹ Hello Developers,

If you've been on the lookout for an out-of-the-box DTO Validator, your search ends here! ExpressoTS now offers a pre-integrated DTO Validator to make your life easier. πŸŽ‰

πŸ‘‰ Learn More

Here's how simple it is to use:

@httpPost("/", ValidateDTO(CreateUserDTO))
execute(@requestBody() payload: CreateUserDTO, @response() res: Response) {
  return res.status(StatusCode.Created).json(this.createUserUseCase.execute(payload));
}
Enter fullscreen mode Exit fullscreen mode

✨ Customization Flexibility

However, if our DTO Validator doesn't quite fit your unique needs, you're free to create your own provider! We've designed our system to be extensible, allowing you to plug in your own solutions.

Here's the signature you need to implement for your custom provider:

const yourprovider = (req: Request, res: Response, next: NextFunction) => { }
Enter fullscreen mode Exit fullscreen mode

Add it to the endpoint decorator and voila, you've replaced ValidateDTO with your own solution! πŸ› οΈ

For more information read the Official Documentation

ExpressoTS #DTOValidator #Customization #NodeJS #BackendDevelopment

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up