Skip to content
Advertisement

Why spring validator is not working in this Api?

I have written a basic simple API of students data and added few validations using Hibernate validator but everytime its returning 0 errors.

Here’s the code:

pom.xml

JavaScript

student.java

JavaScript

Controller.java

JavaScript

I am testing it using postman,My request body:

JavaScript

In every request,even if name is empty Its returning 0 errors.

JavaScript

Can someone help? Thanks in advance.

Advertisement

Answer

you need to add starter validation dependency. Then spring boot auto-configuration will pick the validation related configuration from classpath.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement