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

com.pig4cloud.plugin.excel.kit.Validators Maven / Gradle / Ivy

There is a newer version: 3.3.1
Show newest version
package com.pig4cloud.plugin.excel.kit;

import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validation;
import jakarta.validation.Validator;
import jakarta.validation.ValidatorFactory;

import java.util.Set;

/**
 * 校验工具
 *
 * @author L.cm
 */
public final class Validators {

	private Validators() {
	}

	private static final Validator VALIDATOR;

	static {
		ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
		VALIDATOR = factory.getValidator();
	}

	/**
	 * Validates all constraints on {@code object}.
	 * @param object object to validate
	 * @param  the type of the object to validate
	 * @return constraint violations or an empty set if none
	 * @throws IllegalArgumentException if object is {@code null} or if {@code null} is
	 * passed to the varargs groups
	 * @throws ValidationException if a non recoverable error happens during the
	 * validation process
	 */
	public static  Set> validate(T object) {
		return VALIDATOR.validate(object);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy