Class: ConvertSdk::ConfigValidator
- Inherits:
-
Object
- Object
- ConvertSdk::ConfigValidator
- Defined in:
- lib/convert_sdk/config_validator.rb
Overview
The fail-fast validation rules for Config — the SDK's only raising surface.
+ConfigValidator+ holds every presence/type rule for the configuration surface, extracted from Config so the surface class stays focused on naming-world translation and typed readers while the (uniform, table-like) validation rules live in one cohesive place. Every violation raises a stdlib +ArgumentError+ naming the offending option and the expected type; there is no custom exception hierarchy anywhere in the SDK (Decision 3).
Rules:
- presence — at least one of +sdk_key+ / +data+ must be present (FR6);
- strings — +sdk_key+ / +sdk_key_secret+ / +environment+ / +config_endpoint+ / +track_endpoint+ / +negation+ must be String (nil accepted for the optional ones); +data+ must be a Hash when present;
- integers — +max_traffic+ / +hash_seed+ / +event_batch_size+;
- intervals — +data_refresh_interval+ / +flush_interval+ are Numeric or nil (nil = timer-off); +open_timeout+ / +read_timeout+ are Numeric;
- booleans — +keys_case_sensitive+ / +tracking+ (strict true/false);
- log level — must be one of the LogLevel values.
Constant Summary collapse
- LOG_LEVEL_VALUES =
The accepted LogLevel integer values (TRACE..SILENT).
[ LogLevel::TRACE, LogLevel::DEBUG, LogLevel::INFO, LogLevel::WARN, LogLevel::ERROR, LogLevel::SILENT ].freeze
Instance Method Summary collapse
-
#initialize(values) ⇒ ConfigValidator
constructor
A new instance of ConfigValidator.
-
#validate! ⇒ void
Run every rule.
Constructor Details
#initialize(values) ⇒ ConfigValidator
Returns a new instance of ConfigValidator.
33 34 35 |
# File 'lib/convert_sdk/config_validator.rb', line 33 def initialize(values) @values = values end |
Instance Method Details
#validate! ⇒ void
This method returns an undefined value.
Run every rule. The first violation raises; presence is checked first so a wholly-empty config reports the most useful fault.
42 43 44 45 46 47 48 49 |
# File 'lib/convert_sdk/config_validator.rb', line 42 def validate! validate_presence! validate_strings! validate_integers! validate_intervals! validate_booleans! validate_log_level! end |