Method: Cloudfront::Helpers::CacheBehavior#validate

Defined in:
lib/cloudfront/helpers/cache_behavior.rb

#validateObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cloudfront/helpers/cache_behavior.rb', line 34

def validate
  # some wrapping
  @cookies_to_forward = Array.wrap @cookies_to_forward

  # Error checking
  error_messages.push "target_origin_id shouldn't be nil" if @target_origin_id.nil?
  error_messages.push "query_string_forward must be a boolean" unless !!@query_string_forward == @query_string_forward
  error_messages.push "cookies_forward_policy should be one of #{Cloudfront::Utils::Util::FORWARD_POLICY_VALUES.join(', ')}" unless Cloudfront::Utils::Util::FORWARD_POLICY_VALUES.include?(@cookies_forward_policy)
  # trusted signers validation
  if @trusted_signers.is_a?(TrustedSigners)
    @trusted_signers.check_configuration
  else
    error_messages.push "trusted_signer field should be a TrustedSigners"
  end

  error_messages.push "viewer_protocol_policy should be one of #{Cloudfront::Utils::Util::VIEWER_PROTOCOL_VALUES.join(', ')}" unless Cloudfront::Utils::Util::VIEWER_PROTOCOL_VALUES.include?(@viewer_protocol_policy)
  error_messages.push "min_ttl should be a number" unless @min_ttl.is_a? Fixnum
end