package com.zjrs.appcomm.validation;

import cn.hutool.core.util.StrUtil;

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

/**
 * 验证金额格式
 * @author Pettyfer
 */
public class MoneyValidator implements ConstraintValidator<Money, String>  {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        if (StrUtil.isEmpty(value)) {
            return true;
        }
        return value.matches("^([1-9]\\d{0,9}|0)([.]?|(\\.\\d{0,6})?)$");
    }
}
