We need more validation around adding a match. Currently, you add matches in which individual games are ties, or even the entire match is a tie. For instance, you can enter the default scores, 11 to 11 in both games, and it works fine.
We should check that:
- One player wins two of the games.
- One player does NOT win three games (could affect ratings strangely).
- The scores in all games are different.
- Winning score is 11 if losing score is 9 or less.
- Winning score is NEVER less than 11.
- Losing score is AT LEAST 2 less than the winning score.
Mongoose has something called statics, so we could just add these to the match schema. I would like to see us, generally, move more of the logic to the schemas, since we're really doing operations against Matches and Players most of the time.
Something like:
Match.statics.validateGame = function(matchObj){
// Do validation
}
Match.statics.validateMatch = function(matchObj){
// Do validation
}
etc...
We need more validation around adding a match. Currently, you add matches in which individual games are ties, or even the entire match is a tie. For instance, you can enter the default scores, 11 to 11 in both games, and it works fine.
We should check that:
Mongoose has something called statics, so we could just add these to the match schema. I would like to see us, generally, move more of the logic to the schemas, since we're really doing operations against Matches and Players most of the time.
Something like:
etc...