Module: ExtendedValidator::SpeciesValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_order(order) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/models/extended_validator/species_validator.rb', line 3

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