Package org.confng.validation
Class ConfigValidator
- java.lang.Object
-
- org.confng.validation.ConfigValidator
-
public class ConfigValidator extends Object
Validates configuration values against defined constraints.This class scans ConfNGKey enum constants for validation annotations and checks that the resolved configuration values satisfy all constraints.
Supported annotations:
Required- Value must be presentNotEmpty- Value must not be empty or blankPattern- Value must match a regex patternRange- Numeric value must be within a range
Example usage:
ValidationResult result = ConfNG.validate(); if (!result.isValid()) { throw new RuntimeException(result.getSummary()); }- Since:
- 1.1.0
- Author:
- Bharat Kumar Malviya, GitHub: github.com/imBharatMalviya
- See Also:
ValidationResult,ValidationError
-
-
Constructor Summary
Constructors Constructor Description ConfigValidator(Function<ConfNGKey,String> valueResolver)Creates a new ConfigValidator with the given value resolver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValidationResultvalidate(List<ConfNGKey> keys)Validates all discovered ConfNGKey implementations.
-
-
-
Method Detail
-
validate
public ValidationResult validate(List<ConfNGKey> keys)
Validates all discovered ConfNGKey implementations.- Parameters:
keys- the configuration keys to validate- Returns:
- the validation result
-
-