Class: Kontena::Cli::Stacks::YAML::Validations::CustomValidators::CertificatesValidator

Inherits:
HashValidator::Validator::Base
  • Object
show all
Defined in:
lib/kontena/cli/stacks/yaml/custom_validators/certificates_validator.rb

Instance Method Summary collapse

Constructor Details

#initializeCertificatesValidator

Returns a new instance of CertificatesValidator.



3
4
5
# File 'lib/kontena/cli/stacks/yaml/custom_validators/certificates_validator.rb', line 3

def initialize
  super('stacks_valid_certificates')
end

Instance Method Details

#validate(key, value, validations, errors) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kontena/cli/stacks/yaml/custom_validators/certificates_validator.rb', line 7

def validate(key, value, validations, errors)
  unless value.is_a?(Array)
    errors[key] = 'certificates must be array'
    return
  end
  certificate_item_validation = {
    'subject' => 'string',
    'name' => 'string',
    'type' => 'string'
  }
  value.each do |certificate|
    HashValidator.validator_for(certificate_item_validation).validate(key, certificate, certificate_item_validation, errors)
  end
end