Class: Dragnet::Validators::Fields::ReposValidator
- Inherits:
-
FieldValidator
- Object
- FieldValidator
- Dragnet::Validators::Fields::ReposValidator
- Defined in:
- lib/dragnet/validators/fields/repos_validator.rb
Overview
Validates that the repos
attribute in an MTR is valid. This means:
-
It is either a
Hash
or anArray
of Hashes. -
The attributes inside each of the Hashes are also valid.
Instance Method Summary collapse
-
#validate(key, value) ⇒ Array<Dragnet::Repo>?
Validates the MTR's
repos
field.
Instance Method Details
#validate(key, value) ⇒ Array<Dragnet::Repo>?
Validates the MTR's repos
field.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dragnet/validators/fields/repos_validator.rb', line 23 def validate(key, value) return unless value validate_type(key, value, Hash, Array) if value.is_a?(Array) return if value.empty? validate_array_types(key, value, Hash) else # This is needed because trying to apply the splat operator over a # Hash will result in an Array of Arrays (one for each of the Hash's # key pairs). value = [value] end create_repos(value) end |