Package org.confng.validation
Class ValidationResult
- java.lang.Object
-
- org.confng.validation.ValidationResult
-
public class ValidationResult extends Object
Contains the results of configuration validation.This class holds a collection of validation errors and provides methods to check if validation passed and to retrieve error details.
Example usage:
ValidationResult result = ConfNG.validate(); if (!result.isValid()) { System.err.println("Configuration validation failed:"); for (ValidationError error : result.getErrors()) { System.err.println(" - " + error.getMessage()); } }- Since:
- 1.1.0
- Author:
- Bharat Kumar Malviya, GitHub: github.com/imBharatMalviya
- See Also:
ValidationError,ConfigValidator
-
-
Constructor Summary
Constructors Constructor Description ValidationResult(List<ValidationError> errors)Creates a new ValidationResult with the given errors.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetErrorCount()Gets the number of validation errors.List<ValidationError>getErrors()Gets all validation errors.List<ValidationError>getErrorsByType(ValidationError.ConstraintType constraintType)Gets validation errors of a specific constraint type.List<ValidationError>getErrorsForKey(String key)Gets validation errors for a specific key.StringgetSummary()Gets a formatted summary of all validation errors.booleanhasErrors()Checks if the validation failed (has errors).booleanisValid()Checks if the validation passed (no errors).StringtoString()static ValidationResultvalid()Creates an empty (valid) ValidationResult.
-
-
-
Constructor Detail
-
ValidationResult
public ValidationResult(List<ValidationError> errors)
Creates a new ValidationResult with the given errors.- Parameters:
errors- the list of validation errors
-
-
Method Detail
-
valid
public static ValidationResult valid()
Creates an empty (valid) ValidationResult.- Returns:
- a valid result with no errors
-
isValid
public boolean isValid()
Checks if the validation passed (no errors).- Returns:
- true if there are no validation errors
-
hasErrors
public boolean hasErrors()
Checks if the validation failed (has errors).- Returns:
- true if there are validation errors
-
getErrorCount
public int getErrorCount()
Gets the number of validation errors.- Returns:
- the error count
-
getErrors
public List<ValidationError> getErrors()
Gets all validation errors.- Returns:
- an unmodifiable list of errors
-
getErrorsForKey
public List<ValidationError> getErrorsForKey(String key)
Gets validation errors for a specific key.- Parameters:
key- the configuration key- Returns:
- list of errors for the key
-
getErrorsByType
public List<ValidationError> getErrorsByType(ValidationError.ConstraintType constraintType)
Gets validation errors of a specific constraint type.- Parameters:
constraintType- the constraint type- Returns:
- list of errors of that type
-
getSummary
public String getSummary()
Gets a formatted summary of all validation errors.- Returns:
- a human-readable summary
-
-