yangys
2024-04-01 a36d93e531c292240dc59cb8e712b2eca21a4066
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.qianwen.smartman.common.validator.phone;
 
import cn.hutool.core.util.StrUtil;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
 
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/common/validator/phone/PhoneValueValidator.class */
public class PhoneValueValidator implements ConstraintValidator<PhoneValue, String> {
    private Boolean required;
 
    public void initialize(PhoneValue constraintAnnotation) {
        this.required = Boolean.valueOf(constraintAnnotation.required());
    }
 
    public boolean isValid(String phoneValue, ConstraintValidatorContext context) {
        if (!StrUtil.isEmpty(phoneValue)) {
            return phoneValue.length() == 11;
        } else if (this.required.booleanValue()) {
            return false;
        } else {
            return true;
        }
    }
}