package com.ruoyi.ext.api.validate;

import com.ruoyi.ext.api.utils.IDCardUtil;
import org.apache.commons.lang3.StringUtils;

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

/**
 * 自定义身份证校验注解实现
 * 
 * @author ruoyi
 */
public class IdCardValidator implements ConstraintValidator<IdCardV, String>
{
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (StringUtils.isBlank(value)){
            return true;
        }
        return IDCardUtil.idCardValidate(value);
    }
}