com.lx.boot.web.valid.CheckValidatorFunctions 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.boot.OS;
import com.lx.entity.Var;
import com.lx.util.LX;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
public interface CheckValidatorFunctions {
@Note("ext 参数指定的字段不能全部为空! 注解需作用于实体上")
public class NotAllEmpty implements Function{
@Override
public Boolean apply(Validate validate) {
String[] fields = validate.getExt();
Var map = LX.toMap(validate.getObject());
for (String filedName : fields) {
if (LX.isNotEmpty(map.get(filedName))){
return true;
}
}
return false;
}
}
@Note("ext 参数指定的类型的UserType不能为空!")
public class NotEmptyByUserTypes implements Function{
@Override
public Boolean apply(Validate validate) {
//参数不为空直接放行
if (LX.isNotEmpty(validate.getObject())){
return true;
}
List list = Arrays.asList(validate.getExt());
// 当前用户类型不在指定范围,可以为空.
return !list.contains(OS.getUserType());
}
}
@Note("ext 参数指定的类型的UserType才可以为空!")
public class CanEmptyByUserTypes implements Function{
@Override
public Boolean apply(Validate validate) {
//参数不为空直接放行
if (LX.isNotEmpty(validate.getObject())){
return true;
}
List list = Arrays.asList(validate.getExt());
// 当前用户类型在指定范围可以为空,否则报错
return list.contains(OS.getUserType());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy