package cn.superdesk.uniorder.common.excel.validate.constraint;

import cn.hutool.core.util.StrUtil;
import cn.superdesk.uniorder.common.excel.validate.annotion.RelationTableSysEnterpriseExtInvoiceFieldTaxpayersIDCode;

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

public class RelationTableSysEnterpriseExtInvoiceFieldTaxpayersIDCodeValidator implements ConstraintValidator<RelationTableSysEnterpriseExtInvoiceFieldTaxpayersIDCode, String> {

	/**
	 * 是否强制校验(必须)
	 */
	private boolean required;


	@Override
	public void initialize(RelationTableSysEnterpriseExtInvoiceFieldTaxpayersIDCode constraintAnnotation) {
		this.required = constraintAnnotation.required();
	}


	// repeat
	@Override
	public boolean isValid(String name, ConstraintValidatorContext constraintValidatorContext) {

		// TODO

		if (required) {
			return !StrUtil.isEmpty(name);
		}
		return false;
	}
}