Module: ConfigSL::Validation
- Included in:
- Config
- Defined in:
- lib/configsl/validation.rb
Overview
TODO:
Implement custom validations.
Validates configuration options.
This will check that all required options are set. Additionally, you can set ‘enum` to an array of valid values for an option.
option :state, type: String, required: true, enum: %w[on off]
Instance Method Summary collapse
-
#valid? ⇒ Boolean
Determine if the configuration is valid.
-
#validate! ⇒ Object
Validate the configuration and raise an error if it is invalid.
Instance Method Details
#valid? ⇒ Boolean
Determine if the configuration is valid.
18 19 20 |
# File 'lib/configsl/validation.rb', line 18 def valid? .keys.all? { |name| option_valid?(name) } end |
#validate! ⇒ Object
Validate the configuration and raise an error if it is invalid.
25 26 27 |
# File 'lib/configsl/validation.rb', line 25 def validate! raise ValidationError, 'Invalid configuration' unless valid? end |