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

org.chobit.commons.validation.CommonPatternValidator Maven / Gradle / Ivy

There is a newer version: 0.1.3.4
Show newest version
package org.chobit.commons.validation;


import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.chobit.commons.enums.CommonRegexPattern;

/**
 * @author robin
 */
public class CommonPatternValidator implements ConstraintValidator {


    private CommonRegexPattern regexPattern;

    @Override
    public void initialize(CommonPattern annotation) {
        this.regexPattern = annotation.pattern();
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {

        if (null == value) {
            return true;
        }

        return this.regexPattern.matches(value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy