Class CommandValidator.ValidationResult

java.lang.Object
com.ultikits.ultitools.abstracts.command.validation.CommandValidator.ValidationResult
Enclosing interface:
CommandValidator

public static final class CommandValidator.ValidationResult extends Object
Result of a validation operation. 验证操作的结果。
  • Field Details

    • valid

      private final boolean valid
    • errorMessage

      private final String errorMessage
    • errorKey

      private final String errorKey
  • Constructor Details

  • Method Details

    • success

      public static CommandValidator.ValidationResult success()
      Creates a successful validation result. 创建成功的验证结果。
      Returns:
      a success result
    • failure

      public static CommandValidator.ValidationResult failure(String errorMessage)
      Creates a failed validation result with a message. 创建带有消息的失败验证结果。
      Parameters:
      errorMessage - the error message
      Returns:
      a failure result
    • failure

      public static CommandValidator.ValidationResult failure(String errorMessage, String errorKey)
      Creates a failed validation result with a message and i18n key. 创建带有消息和 i18n 键的失败验证结果。
      Parameters:
      errorMessage - the error message
      errorKey - the i18n key for the error
      Returns:
      a failure result
    • isValid

      public boolean isValid()
      Checks if the validation was successful. 检查验证是否成功。
      Returns:
      true if valid
    • getErrorMessage

      @Nullable public String getErrorMessage()
      Gets the error message if validation failed. 获取验证失败时的错误消息。
      Returns:
      the error message, or null if valid
    • getErrorKey

      @Nullable public String getErrorKey()
      Gets the i18n key for the error message. 获取错误消息的 i18n 键。
      Returns:
      the error key, or null if not set