class Kontena::Cli::Stacks::YAML::Validations::CustomValidators::ExtendsValidator

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/kontena/cli/stacks/yaml/custom_validators/extends_validator.rb, line 3
def initialize
  super('stacks_valid_extends')
end

Public Instance Methods

validate(key, value, validations, errors) click to toggle source
# File lib/kontena/cli/stacks/yaml/custom_validators/extends_validator.rb, line 7
def validate(key, value, validations, errors)
  unless value.is_a?(String) || value.is_a?(Hash)
    errors[key] = 'extends must be string or hash'
    return
  end
  if value.is_a?(Hash)
    extends_validation = {
      'service' => 'string',
      'file' => HashValidator.optional('string'),
      'stack' => HashValidator.optional('string')
    }
    HashValidator.validator_for(extends_validation).validate(key, value, extends_validation, errors)
  end
end