8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/zendesk_apps_support/validations/requirements.rb', line 8
def call(package)
if package.manifest.requirements_only? && !package.has_requirements?
return [ValidationError.new(:missing_requirements)]
elsif package.manifest.marketing_only? && package.has_requirements?
return [ValidationError.new(:requirements_not_supported)]
elsif !package.has_requirements?
return []
end
begin
requirements = package.requirements_json
rescue ZendeskAppsSupport::Manifest::OverrideError => e
return [ValidationError.new(:duplicate_requirements, duplicate_keys: e.key, count: 1)]
end
[].tap do |errors|
errors << invalid_requirements_types(requirements)
errors << excessive_requirements(requirements)
errors << invalid_channel_integrations(requirements)
errors << invalid_custom_fields(requirements)
errors << missing_required_fields(requirements)
errors.flatten!
errors.compact!
end
rescue JSON::ParserError => e
return [ValidationError.new(:requirements_not_json, errors: e)]
end
|