All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.houkunlin.system.dict.starter.json.DictValid3ConstraintValidator Maven / Gradle / Ivy

Go to download

系统数据字典自动翻译成字典文本。可集合系统数据库中存储的用户数据字典,也可使用枚举做系统数据字典,主要用在返回数据给前端时自动把字典值翻译成字典文本信息; The system data dictionary is automatically translated into dictionary text. The user data dictionary stored in the system database can be aggregated, and the enumeration can also be used as the system data dictionary. It is mainly used to automatically translate dictionary values into dictionary text information when returning data to the front end.

The newest version!
package com.houkunlin.system.dict.starter.json;

import com.houkunlin.system.dict.starter.DictUtil;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * 校验字典信息是否在字典列表中。校验字典信息的填写是否符合需求
 *
 * @author HouKunLin
 */
public class DictValid3ConstraintValidator implements ConstraintValidator {
    private String dictType;

    @Override
    public boolean isValid(final Object value, final ConstraintValidatorContext context) {
        if (dictType == null || value == null) {
            return false;
        }
        return DictUtil.getDictText(dictType, value.toString()) != null;
    }

    @Override
    public void initialize(final DictValid3 constraintAnnotation) {
        this.dictType = constraintAnnotation.value();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy