Class: Cliqr::Config::Validation::ValidationSet Private
- Inherits:
-
Object
- Object
- Cliqr::Config::Validation::ValidationSet
- Defined in:
- lib/cliqr/config/validation/validation_set.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A collection of configured validators
Instance Method Summary collapse
-
#add(name, options) ⇒ Hash
private
Add a new validator.
-
#each(&block) ⇒ Cliqr::Config::Validation::ValidatorFactory::Validator
private
Iterate over each validators.
-
#each_key(&block) ⇒ Object
private
Iterate over each type of validators.
-
#initialize ⇒ ValidationSet
constructor
private
Initialize a new instance of validation set.
-
#merge(other) ⇒ Cliqr::Config::Validation::ValidationSet
private
Merge validations form another set.
-
#validate(attribute, value, errors) ⇒ Array
private
Run the validators for a attribute against its value.
Constructor Details
#initialize ⇒ ValidationSet
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.
Initialize a new instance of validation set
13 14 15 |
# File 'lib/cliqr/config/validation/validation_set.rb', line 13 def initialize @set = {} end |
Instance Method Details
#add(name, options) ⇒ 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.
Add a new validator
23 24 25 26 |
# File 'lib/cliqr/config/validation/validation_set.rb', line 23 def add(name, ) @set[name] = \ Hash[.map { |type, config| [type, ValidatorFactory.get(type, config)] }] end |
#each(&block) ⇒ Cliqr::Config::Validation::ValidatorFactory::Validator
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.
Iterate over each validators
47 48 49 |
# File 'lib/cliqr/config/validation/validation_set.rb', line 47 def each(&block) @set.each(&block) end |
#each_key(&block) ⇒ 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.
Iterate over each type of validators
40 41 42 |
# File 'lib/cliqr/config/validation/validation_set.rb', line 40 def each_key(&block) @set.each_key(&block) end |
#merge(other) ⇒ Cliqr::Config::Validation::ValidationSet
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.
Merge validations form another set
33 34 35 |
# File 'lib/cliqr/config/validation/validation_set.rb', line 33 def merge(other) other.each { |name, validations| @set[name] = validations } end |
#validate(attribute, value, errors) ⇒ Array
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 validators for a attribute against its value
58 59 60 61 62 |
# File 'lib/cliqr/config/validation/validation_set.rb', line 58 def validate(attribute, value, errors) @set[attribute].values.each do |validator| validator.validate(attribute, value, errors) end end |