Sha256: 215d3acab3609449c045bde890cbe8316bac8fe77adc3e2ba287fcbbf77b0de9

Contents?: true

Size: 658 Bytes

Versions: 7

Compression:

Stored size: 658 Bytes

Contents

module Kontena::Cli::Stacks::YAML::Validations::CustomValidators
  class ExtendsValidator < HashValidator::Validator::Base
    def initialize
      super('stacks_valid_extends')
    end

    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')
        }
        HashValidator.validator_for(extends_validation).validate(key, value, extends_validation, errors)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kontena-cli-1.0.0.pre2 lib/kontena/cli/stacks/yaml/custom_validators/extends_validator.rb
kontena-cli-1.0.0.pre1 lib/kontena/cli/stacks/yaml/custom_validators/extends_validator.rb
kontena-cli-0.17.0.pre5 lib/kontena/cli/stacks/yaml/custom_validators/extends_validator.rb
kontena-cli-0.17.0.pre4 lib/kontena/cli/stacks/yaml/custom_validators/extends_validator.rb
kontena-cli-0.17.0.pre3 lib/kontena/cli/stacks/yaml/custom_validators/extends_validator.rb
kontena-cli-0.17.0.pre2 lib/kontena/cli/stacks/yaml/custom_validators/extends_validator.rb
kontena-cli-0.17.0.pre1 lib/kontena/cli/stacks/yaml/custom_validators/extends_validator.rb