All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.manywho.sdk.utils.ValidationUtils Maven / Gradle / Ivy

There is a newer version: 1.25.0
Show newest version
package com.manywho.sdk.utils;

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validation;
import javax.validation.Validator;
import java.util.Set;

public class ValidationUtils {
    public static void validate(Object entity) {
        Validator validator = Validation.buildDefaultValidatorFactory().getValidator();

        Set> constraintViolations = validator.validate(entity);
        if (!constraintViolations.isEmpty()) {
            throw new ConstraintViolationException(constraintViolations);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy