com.lx.boot.web.valid.Validate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lxboot3 Show documentation
Show all versions of lxboot3 Show documentation
使用文档: https://a7fi97h1rc.feishu.cn/docx/X3LRdtLhkoXQ8hxgXDQc2CLOnEg?from=from_copylink
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