package com.zjrs.appcomm.validation;

import cn.hutool.core.util.StrUtil;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * 数字和字母格式验证
 * @author Pettyfer
 */
public class NumberLettersValidator implements ConstraintValidator<NumberLetters, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        if (StrUtil.isEmpty(value)) {
            return true;
        }
        return value.matches("^[A-Za-z0-9]+$");
    }
}
