Spring Boot Validation
Spring has a Validation interface that we can use to create custom object validation; if some errors occur in the validation process, it stores them in a BindingResult object so you can test for and retrieve validation errors. Let’s consider the following validator implementation:
package com.josdem.springboot.validation.validator; import com.josdem.springboot.validation.command.PersonCommand; import org.springframework.validation.Validator; import org.springframework.validation.Errors; import org.springframework.stereotype.Component; @Component public class PersonValidator implements Validator { private final String REGEX = "[0-9]+"; @Override public boolean supports(Class<?
[Read More]