Class VerifyUtil

java.lang.Object
cn.sinozg.applet.common.utils.VerifyUtil

public class VerifyUtil extends Object
javaBean 参数手动校验
Since:
2024-01-26 17:50
Author:
xieyubin
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final org.slf4j.Logger
    日志
    private static jakarta.validation.Validator
     
    private static org.springframework.validation.SmartValidator
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    errorInfo(org.springframework.validation.BindingResult result)
    获取参数错误信息
    private static <T> org.springframework.validation.DataBinder
    getBinder(T object)
    获取绑定
    static jakarta.validation.Validator
     
    private static org.springframework.validation.SmartValidator
    getValidatorAdapter(jakarta.validation.Validator validator)
     
    static <T> void
    validate(T t)
    校验参数,用于普通参数校验
    static <T> void
    validate(T object, Class<?>... groups)
    校验对象
    static <T> void
    validateBySpring(T object, Class<?>... groups)
    校验对象 使用与 Spring 集成的校验方式。

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • validator

      private static jakarta.validation.Validator validator
    • validatorAdapter

      private static org.springframework.validation.SmartValidator validatorAdapter
    • LOG

      private static final org.slf4j.Logger LOG
      日志
  • Constructor Details

    • VerifyUtil

      private VerifyUtil()
  • Method Details

    • getValidator

      public static jakarta.validation.Validator getValidator()
    • getValidatorAdapter

      private static org.springframework.validation.SmartValidator getValidatorAdapter(jakarta.validation.Validator validator)
    • validate

      public static <T> void validate(T t)
      校验参数,用于普通参数校验
      Parameters:
      t - 参数
    • validate

      public static <T> void validate(T object, Class<?>... groups)
      校验对象
      Type Parameters:
      T - 类型
      Parameters:
      object - 对象
      groups - 组
    • validateBySpring

      public static <T> void validateBySpring(T object, Class<?>... groups)
      校验对象 使用与 Spring 集成的校验方式。
      Type Parameters:
      T - 类型
      Parameters:
      object - 待校验对象
      groups - 待校验的组
    • errorInfo

      public static String errorInfo(org.springframework.validation.BindingResult result)
      获取参数错误信息
      Parameters:
      result - 错误信息
      Returns:
      转化
    • getBinder

      private static <T> org.springframework.validation.DataBinder getBinder(T object)
      获取绑定
      Type Parameters:
      T - 类型
      Parameters:
      object - 参数
      Returns:
      绑定