Class 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 present
    • NotEmpty - Value must not be empty or blank
    • Pattern - Value must match a regex pattern
    • Range - 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 Detail

      • ConfigValidator

        public ConfigValidator​(Function<ConfNGKey,​String> valueResolver)
        Creates a new ConfigValidator with the given value resolver.
        Parameters:
        valueResolver - function to resolve configuration values
    • 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