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

com.lx.boot.web.valid.Validate Maven / Gradle / Ivy

Go to download

使用文档: https://a7fi97h1rc.feishu.cn/docx/X3LRdtLhkoXQ8hxgXDQc2CLOnEg?from=from_copylink

There is a newer version: 1.1
Show newest version
package com.lx.boot.web.valid;

import com.lx.annotation.Note;
import com.lx.util.LX;
import jakarta.validation.ConstraintValidatorContext;
import lombok.AllArgsConstructor;
import lombok.Data;


@Data
@AllArgsConstructor
public class Validate{
    @Note("注解自定义参数!")
    private String value;
    @Note("注解扩展参数!")
    private String[] ext;
    @Note("注解标注的参数!")
    private Object object;
    @Note("注解验证上下文")
    private ConstraintValidatorContext constraintValidatorContext;
    @Note("修改返回信息")
    public void setMessage(String msg){
        this.constraintValidatorContext.disableDefaultConstraintViolation();//禁用默认的message的值
        this.constraintValidatorContext.buildConstraintViolationWithTemplate(msg).addConstraintViolation();
    }

    @Note("判断注解标注的参数是否不为空!")
    public boolean isNotEmpty(){
        return LX.isNotEmpty(object);
    }

    @Note("判断注解标注的参数是否不为null")
    public boolean isNotNull(){
        return object != null;
    }

    @Note("获取注解标注的参数")
    public T getObject(){
        return (T)object;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy