Class: ElementAvitiValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- ElementAvitiValidator
- Defined in:
- app/validators/element_aviti_validator.rb
Class Method Summary collapse
-
.validation_info ⇒ Object
Used in _pipeline_limit.html to display custom validation warnings.
Instance Method Summary collapse
-
#validate(record) ⇒ Object
Adds an error to the record if more than one request exists with a read length of 300.
Class Method Details
.validation_info ⇒ Object
Used in _pipeline_limit.html to display custom validation warnings
4 5 6 |
# File 'app/validators/element_aviti_validator.rb', line 4 def self.validation_info '300PE (MO, HO) require only one request.' end |
Instance Method Details
#validate(record) ⇒ Object
Adds an error to the record if more than one request exists with a read length of 300.
9 10 11 12 13 |
# File 'app/validators/element_aviti_validator.rb', line 9 def validate(record) return if record.requests.one? || record.requests.none? { |r| r..read_length == 300 } record.errors.add(:base, 'Batches can contain only one request when the read length is 300') end |