Class: Stattleship::Validators::StatusValidator

Inherits:
BaseValidator show all
Defined in:
lib/stattleship/validators/status_validator.rb

Constant Summary collapse

VALID_STATUSES =
%w(ended in_progress upcoming).freeze

Instance Method Summary collapse

Methods inherited from BaseValidator

#initialize, #validates_date, #validates_league_prefix, #validates_positive_integer, #validates_positive_or_zero_integer, #validates_sport_prefix

Constructor Details

This class inherits a constructor from Stattleship::Validators::BaseValidator

Instance Method Details

#validateObject


6
7
8
9
10
11
12
13
# File 'lib/stattleship/validators/status_validator.rb', line 6

def validate
  if VALID_STATUSES.include?(value)
    return
  else
    fail ArgumentError.
      new("expected #{key} to be either #{VALID_STATUSES.join(', ')}")
  end
end