Class: ArchiveValidator::CollectionValidator

Inherits:
BaseValidator show all
Defined in:
lib/archive_validator/collection_validator.rb

Instance Attribute Summary

Attributes inherited from BaseValidator

#archive_hash

Instance Method Summary collapse

Methods inherited from BaseValidator

#initialize, #messages, #valid?

Methods included from ArchiveImporter::ArchiveHelper

#archive_author_diaspora_id, #contact_groups, #contacts, #others_relayables, #person, #post_subscriptions, #posts, #private_key, #relayables, #serialized_private_key

Constructor Details

This class inherits a constructor from ArchiveValidator::BaseValidator

Instance Method Details

#validateObject

Runs validations over each element in collection and removes every element which fails the validations. Any messages produced by the entity_validator are concatenated to the messages of the CollectionValidator instance.


8
9
10
11
12
13
14
# File 'lib/archive_validator/collection_validator.rb', line 8

def validate
  collection.keep_if do |item|
    subvalidator = entity_validator.new(archive_hash, item)
    messages.concat(subvalidator.messages)
    subvalidator.valid?
  end
end