Module: Aws::Resources::Validator::DSL

Included in:
Aws::Resources::Validator
Defined in:
aws-sdk-resources/lib/aws-sdk-resources/validator/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
# File 'aws-sdk-resources/lib/aws-sdk-resources/validator/dsl.rb', line 6

def self.extended(base)

  # @api private
  base.const_set(:RULES, [])

  # @api private
  base.const_set(:SCHEMA_PATH, File.expand_path(File.join([
    File.dirname(__FILE__), '..', '..', '..', 'resources.schema.json'
  ])))

end

Instance Method Details

#match(*patterns, &block) ⇒ Object


18
19
20
21
22
# File 'aws-sdk-resources/lib/aws-sdk-resources/validator/dsl.rb', line 18

def match(*patterns, &block)
  patterns.each do |pattern|
    RULES << Rule.new(pattern, &block)
  end
end

#validate(definition, api) ⇒ Array<String>

Parameters:

  • definition (Hash)
  • api (Hash)

Returns:

  • (Array<String>)

27
28
29
30
31
32
33
34
# File 'aws-sdk-resources/lib/aws-sdk-resources/validator/dsl.rb', line 27

def validate(definition, api)
  errors = validate_against_schema(definition)
  if errors.empty?
    lint(new_context(definition, api))
  else
    errors
  end
end