6
7
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
|
# File 'lib/multi_video_streaming/validators/platforms_hash_validator.rb', line 6
def self.validate(platforms_hash: [], method:, number_of_platforms: 0)
platform_names = []
platforms_hash.each do |platform_hash|
if (platform_hash.nil? || platform_hash[:platform_name].nil?)
raise MultiVideoStreaming::Errors::MissingParam.new('platform_name')
end
if (platform_hash[:dependency_params].nil?)
raise MultiVideoStreaming::Errors::MissingParam.new('dependency_params')
end
if method == :create && platform_hash[:platform_name] == "s3"
if number_of_platforms > 1
return
else
raise MultiVideoStreaming::Errors::S3IsNotValidToUpload.new
end
end
MultiVideoStreaming::Validators::PlatformNameValidator.validate(name: platform_hash[:platform_name])
if platform_names.include?(platform_hash[:platform_name])
raise MultiVideoStreaming::Errors::DuplicatedPlatformName.new
else
platform_names << platform_hash[:platform_name]
end
end
end
|