Class: ElementAvitiValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/validators/element_aviti_validator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.validation_infoObject

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

Validates that a batch contains the correct number of requests based on read length.

  • If any request has a read length of 300, the batch must contain exactly one request.

  • Otherwise, the batch must contain exactly two requests.

Adds errors to the record if these conditions are not met.



14
15
16
17
18
19
20
# File 'app/validators/element_aviti_validator.rb', line 14

def validate(record)
  if record.requests.any? { |r| r..read_length == 300 }
    validate_single_request_for_read_length300(record)
  else
    validate_exactly_two_requests(record)
  end
end