Validation API Request using annotation in spring boot

Published: 15 September 2022
on channel: Programming Tutorial
42
like

#validation #validationinspringboot #validationapirequest #validationusingannotation
You can download this project on my github (https://github.com/AminTurmudiYusup/s...)
Validation API Request using annotation
Prerequisite
1. You familiar implement spring boot app from scratch
2. You understand implementing validation requests, using a programmatic approach
3. Understand implementing globalException handler (if not you can check my previous tutorial, how to create global handler spring boot)


In the previous tutorial, i validate API request using a programmatic approach.
In this tutorial i will validation using annotation approach.

Purpose validation request using annotation?
1. simplicity of code
2. reduce boilerplate code
3. services layer focus on busines logic not validation


Let's jump right in
1. open pom.xml and add validation dependency
2. open entity class which handle request
3. add validation using annotation in entity class
4. add @valid annotation in controller which handle request
5. open global handler and create method for check, that entity sent to server is valid
6. Delete all validation in service layer
7. try to run app
You can download this tutorial in my github
Happy learning and happy sharing!!!


On this page of the site you can watch the video online Validation API Request using annotation in spring boot with a duration of hours minute second in good quality, which was uploaded by the user Programming Tutorial 15 September 2022, share the link with friends and acquaintances, this video has already been watched 42 times on youtube and it was liked by like viewers. Enjoy your viewing!