Module: Aws::Xray::AnnotationValidator

Extended by:
AnnotationValidator
Included in:
AnnotationValidator
Defined in:
lib/aws/xray/annotation_validator.rb

Instance Method Summary collapse

Instance Method Details

#call(h) ⇒ Object

Parameters:

  • h (Hash)

    annotation hash.

Raises:

  • RuntimeError



8
9
10
11
12
13
# File 'lib/aws/xray/annotation_validator.rb', line 8

def call(h)
  invalid_keys = h.keys.reject {|k| k.to_s.match(/\A[A-Za-z0-9_]+\z/) }
  raise 'Keys must be alphanumeric and underscore string' unless invalid_keys.empty?
  invalid_values = h.values.reject {|v| v.is_a?(String) || v.is_a?(Integer) || (v == true || v == false) }
  raise 'Values must be one of String or Integer or Boolean values' unless invalid_values.empty?
end