287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
# File 'lib/praxis/types/multipart_array.rb', line 287
def validate(context=Attributor::DEFAULT_ROOT_CONTEXT)
errors = self.each_with_index.each_with_object([]) do |(part, idx), errors|
sub_context = if part.name
self.class.generate_subcontext(context, part.name)
else
context + ["at(#{idx})"]
end
errors.push *part.validate(sub_context)
end
self.class.attributes.each do |name, attribute|
payload_attribute = attribute.options[:payload_attribute]
next unless payload_attribute.options[:required]
next if self.part(name)
sub_context = self.class.generate_subcontext(context, name)
errors.push *payload_attribute.validate_missing_value(sub_context)
end
errors
end
|