41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/facebook_ads/ad_targeting.rb', line 41
def validate!
{ gender: genders, countries: countries, user_os: user_os, user_device: user_device, custom_locations: custom_locations }.each_pair do |key, array|
raise ArgumentError, "#{self.class.name}: #{key} must be an array" if !array.nil? && !array.is_a?(Array)
end
{ genders: [genders, GENDERS], user_os: [user_os, OSES], user_device: [user_device, DEVICES] }.each_pair do |key, provided_and_acceptable|
provided, acceptable = provided_and_acceptable
if !provided.nil? && !(invalid = provided.detect { |value| !acceptable.include?(value) }).nil?
raise ArgumentError, "#{self.class.name}: #{invalid} is an invalid #{key}"
end
end
true
end
|