Sha256: 39903ea3b1e9a4555f22943d440cdc0c81d18290f656b105edcf1d2fd8354520
Contents?: true
Size: 1.08 KB
Versions: 86
Compression:
Stored size: 1.08 KB
Contents
require 'hash_validator' module Kontena::Cli::Apps module YAML class Validator require_relative 'validations' include Validations def initialize(need_image=false) @schema = common_validations @schema['build'] = optional('string') @schema['dockerfile'] = optional('string') @schema['net'] = optional(%w(host bridge)) @schema['log_driver'] = optional('string') @schema['log_opts'] = optional({}) Validations::CustomValidators.load end ## # @param [Hash] yaml # @return [Array] validation_errors def validate(yaml) result = { errors: [], notifications: [] } yaml.each do |service, options| unless options.is_a?(Hash) result[:errors] << { service => { 'options' => 'must be a mapping not a string'} } next end option_errors = validate_options(options) result[:errors] << { service => option_errors.errors } unless option_errors.valid? end result end end end end
Version data entries
86 entries across 86 versions & 2 rubygems