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
35
36
37
38
39
40
|
# File 'lib/zendesk_apps_support/validations/requirements.rb', line 10
def call(package)
if package.manifest.requirements_only? && !package.has_requirements?
return [ValidationError.new(:missing_requirements)]
elsif !supports_requirements(package) && 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 << excessive_custom_objects_requirements(requirements)
errors << invalid_channel_integrations(requirements)
errors << invalid_custom_fields(requirements)
errors << invalid_custom_objects(requirements)
errors << invalid_webhooks(requirements)
errors << invalid_target_types(requirements)
errors << missing_required_fields(requirements)
errors.flatten!
errors.compact!
end
rescue JSON::ParserError => e
return [ValidationError.new(:requirements_not_json, errors: e)]
end
|