Module: ExtendedValidator::SpeciesValidator

Defined in:
app/models/extended_validator/species_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_order(order) ⇒ Object


2
3
4
5
6
7
8
# File 'app/models/extended_validator/species_validator.rb', line 2

def validate_order(order)
  bad_samples = order.all_samples.select { |s| s..sample_taxon_id != options[:taxon_id] }
  return true if bad_samples.empty?

  order.errors.add(:samples, "should have taxon_id #{options[:taxon_id]}: problems with #{bad_samples.map(&:sanger_sample_id).to_sentence}.")
  false
end