class MatchValidation::Validator

Help validate the changes to match attributes

Public Class Methods

new(match) click to toggle source
# File app/models/concerns/match_validation.rb, line 22
def initialize(match)
  @match = match
end

Public Instance Methods

validate(errors) click to toggle source

Check for various error conditions:

  • Both opponents may not be the same team or player

  • The server of the second doubles game must be valid

    • Must not be on the same team as the server of the first

  • The :scoring kind must be known

  • The opponents must be known

  • The attributes must be permitted to change

    • Many attributes can not be changed after the match has started

      • opponents

      • doubles

      • scoring kind

  • Params

    • :errors - hash

      • Errors will be added to this hash

# File app/models/concerns/match_validation.rb, line 40
def validate(errors)
  that_first_and_second_opponents_different(errors)
  that_player_servers_on_different_teams(errors)
  that_scoring_is_known(errors)
  that_can_change_after_start_play(errors)
  that_teams_or_players_are_present(errors)
end