Class: Stattleship::Validators::StatValidator

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

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

Raises:

  • (ArgumentError)

4
5
6
7
8
9
10
11
12
13
14
# File 'lib/stattleship/validators/stat_validator.rb', line 4

def validate
  if present?(value) && present?(stat_type)
    return
  end

  if blank?(value)
    raise ArgumentError.new('expected stat')
  end

  raise ArgumentError.new('expected stat and type')
end