Package dev.voidframework.validation
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
A validation result.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <VALIDATED_OBJ_TYPE>
Validated<VALIDATED_OBJ_TYPE>emptyOf()
Creates an empty validated object.static <VALIDATED_OBJ_TYPE>
Validated<VALIDATED_OBJ_TYPE>emptyOf
(VALIDATED_OBJ_TYPE instance) Creates an empty validated object.getError()
Returns all errors of validated object.Returns a single error for the specific path of validated object.getErrorList
(String path) Returns all errors for the specific path of validated object.Returns instance of the validated object.boolean
hasError()
Indicates if validated object has errors.boolean
Indicates if the specific path of validated object has errors.boolean
isValid()
Indicates if validated object is valid.
-
Method Details
-
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, otherwisefalse
-
hasError
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, otherwisefalse
-
isValid
public boolean isValid()Indicates if validated object is valid.- Returns:
true
if validated object has no errors, otherwisefalse
-
getError
Returns all errors of validated object.- Returns:
- All errors group by path
-
getError
Returns a single error for the specific path of validated object.- Parameters:
path
- The path- Returns:
- The error if exists, otherwise,
null
-
getErrorList
Returns all errors for the specific path of validated object.- Parameters:
path
- The path- Returns:
- The error if exists, otherwise,
null
-
getInstance
Returns instance of the validated object.- Returns:
- The validated object
-