Class: Validators::StockStateValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Validators::StockStateValidator
- Defined in:
- app/models/validators/stock_state_validator.rb
Overview
There are a number of common issues with submission. This validator detects them to provide more feedback to the user. It only gets used if a stock plate is stuck at pending, so performance is not critical
Defined Under Namespace
Classes: Analyzer
Instance Method Summary collapse
-
#validate(presenter) ⇒ Object
rubocop:todo Metrics/AbcSize.
Instance Method Details
#validate(presenter) ⇒ Object
rubocop:todo Metrics/AbcSize
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/models/validators/stock_state_validator.rb', line 65 def validate(presenter) # rubocop:todo Metrics/AbcSize analyzer = Analyzer.new(presenter.labware) if analyzer.no_submission? presenter.errors.add(:plate, 'has no requests. Please check that your submission built correctly.') elsif analyzer.no_samples? presenter.errors.add(:plate, 'has no samples. Did the cherry-pick complete successfully?') else if analyzer.duplicates? presenter.errors.add(:plate, "has multiple submissions on: #{analyzer.duplicates.to_sentence}") end presenter.errors.add(:plate, "has no submissions on: #{analyzer.missing.to_sentence}") if analyzer.missing? if analyzer.empty_wells_with_requests? presenter.errors.add(:plate, "has requests on empty wells: #{analyzer.empty_wells_with_requests.to_sentence}") end end end |