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

cn.allbs.hj212.validator.field.CValidator Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package cn.allbs.hj212.validator.field;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author ChenQi
 */
public class CValidator implements ConstraintValidator {

    private int max;

    @Override
    public void initialize(C validDate) {
        this.max = validDate.len();
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        int len;
        if (value == null) {
            len = 0;
        } else {
            len = value.length();
        }
        return len <= max;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy