com.nls.validation.RequiredValidator Maven / Gradle / Ivy
The newest version!
package com.nls.validation;
import com.google.common.base.Strings;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class RequiredValidator implements ConstraintValidator {
private boolean trim;
public void initialize(Required parameters) {
trim = parameters.trim();
}
public boolean isValid(String object, ConstraintValidatorContext context) {
return trim ? !Strings.isNullOrEmpty(Strings.nullToEmpty(object).trim()) : !Strings.isNullOrEmpty(object);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy