Class Validated<VALIDATED_OBJ_TYPE>

java.lang.Object
dev.voidframework.validation.Validated<VALIDATED_OBJ_TYPE>
Type Parameters:
VALIDATED_OBJ_TYPE - Type of the validated object

public class Validated<VALIDATED_OBJ_TYPE> extends Object
A validation result.
  • Method Details

    • emptyOf

      public static <VALIDATED_OBJ_TYPE> Validated<VALIDATED_OBJ_TYPE> emptyOf()
      Creates an empty validated object.
      Type Parameters:
      VALIDATED_OBJ_TYPE - Type of the validated object
      Returns:
      Newly created instance
    • emptyOf

      public static <VALIDATED_OBJ_TYPE> Validated<VALIDATED_OBJ_TYPE> emptyOf(VALIDATED_OBJ_TYPE instance)
      Creates an empty validated object.
      Type Parameters:
      VALIDATED_OBJ_TYPE - Type of the validated object
      Parameters:
      instance - The validated object instance
      Returns:
      Newly created instance
    • hasError

      public boolean hasError()
      Indicates if validated object has errors.
      Returns:
      true if validated object has one error or more, otherwise false
    • hasError

      public boolean hasError(String path)
      Indicates if the specific path of validated object has errors.
      Parameters:
      path - The path
      Returns:
      true if the specific path of validated object has one error or more, otherwise false
    • isValid

      public boolean isValid()
      Indicates if validated object is valid.
      Returns:
      true if validated object has no errors, otherwise false
    • getError

      public Map<String,List<ValidationError>> getError()
      Returns all errors of validated object.
      Returns:
      All errors group by path
    • getError

      public ValidationError getError(String path)
      Returns a single error for the specific path of validated object.
      Parameters:
      path - The path
      Returns:
      The error if exists, otherwise, null
    • getErrorList

      public List<ValidationError> getErrorList(String path)
      Returns all errors for the specific path of validated object.
      Parameters:
      path - The path
      Returns:
      The error if exists, otherwise, null
    • getInstance

      public VALIDATED_OBJ_TYPE getInstance()
      Returns instance of the validated object.
      Returns:
      The validated object