Spring-Boot Microservice with JPA – Enabling validation

package com.mcf7.spring.domain;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;


public class BeforeCreateBookValidator implements Validator{
    public boolean supports(Class<?> clazz) {
        return Book.class.equals(clazz);
    }

    public void validate(Object target, Errors errors) {
        errors.reject("rejected");
    }
}

if you want to reproduce, please indicate the source:
Spring-Boot Microservice with JPA – Enabling validation - CodeDay