Module: Cliqr::Config::Validation Private
- Included in:
- Base
- Defined in:
- lib/cliqr/config/validation/verifiable.rb,
lib/cliqr/config/validation/validation_set.rb,
lib/cliqr/config/validation/validator_factory.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Validation framework for the command line interface config definition adopted from lotus/validations by @jodosha
Defined Under Namespace
Modules: ValidatorFactory, Verifiable Classes: ValidationSet
Class Method Summary collapse
-
.included(base) ⇒ Object
private
If a class includes this module, we add a few useful methods to that class.
Instance Method Summary collapse
-
#errors ⇒ Cliqr::ValidationErrors
private
Get a list of errors after validation finishes.
-
#read_attributes ⇒ Hash
private
Read current values for all attributes that must be validated.
-
#valid? ⇒ Boolean
private
Check if the class is valid based on the configured attribute validations.
-
#validate ⇒ Hash
private
Run the validation against all attribute values.
-
#validations ⇒ Hash
private
Get the list of validations to be performed.
Class Method Details
.included(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
If a class includes this module, we add a few useful methods to that class
21 22 23 24 25 |
# File 'lib/cliqr/config/validation/verifiable.rb', line 21 def self.included(base) base.class_eval do extend Verifiable end end |
Instance Method Details
#errors ⇒ Cliqr::ValidationErrors
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get a list of errors after validation finishes
66 67 68 |
# File 'lib/cliqr/config/validation/verifiable.rb', line 66 def errors @errors ||= ValidationErrors.new end |
#read_attributes ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Read current values for all attributes that must be validated
55 56 57 58 59 60 61 |
# File 'lib/cliqr/config/validation/verifiable.rb', line 55 def read_attributes {}.tap do |attributes| validations.each_key do |attribute| attributes[attribute] = public_send(attribute) end end end |
#valid? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if the class is valid based on the configured attribute validations
30 31 32 33 34 |
# File 'lib/cliqr/config/validation/verifiable.rb', line 30 def valid? validate errors.empty? end |
#validate ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run the validation against all attribute values
39 40 41 42 43 |
# File 'lib/cliqr/config/validation/verifiable.rb', line 39 def validate read_attributes.each do |name, value| validations.validate(name, value, errors) end end |
#validations ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the list of validations to be performed
48 49 50 |
# File 'lib/cliqr/config/validation/verifiable.rb', line 48 def validations self.class.__send__(:validations) end |