Module: Reading::DatesValidator

Defined in:
lib/reading/attribute/experiences/dates_validator.rb

Overview

Methods to validate dates. This does not cover all the ways dates can be invalid, just the ones not covered by ExperiencesAttribute during parsing.

Class Method Summary collapse

Class Method Details

.validate(experiences, config) ⇒ Object

Checks the dates in the given experiences hash, and raises an error at the first invalid date found.

Parameters:



12
13
14
15
16
17
# File 'lib/reading/attribute/experiences/dates_validator.rb', line 12

def validate(experiences, config)
  validate_dates_started_are_in_order(experiences) if dates_started_column?(config)
  validate_dates_finished_are_in_order(experiences) if dates_finished_column?(config)
  validate_experiences_of_same_variant_do_not_overlap(experiences) if both_date_columns?(config)
  validate_spans_are_in_order_and_not_overlapping(experiences)
end