better validate tournament rating condition form

This commit is contained in:
Thibault Duplessis 2018-04-14 02:20:02 +02:00
parent 34940348ec
commit 010db29a36
2 changed files with 7 additions and 0 deletions

View file

@ -77,6 +77,7 @@ moreJs = moreJs) {
</table>
<fieldset class="conditions">
<legend>&nbsp;Advanced settings&nbsp;</legend>
@errMsg(form("conditions"))
<p>
<strong data-icon="!" class="text">We recommend not touching these.</strong>
If you set conditions of entry, your tournament will have fewer players.

View file

@ -246,6 +246,7 @@ object Condition {
"minRating" -> minRating,
"titled" -> boolean
)(AllSetup.apply)(AllSetup.unapply)
.verifying("Invalid ratings", _.validRatings)
case class AllSetup(
nbRatedGame: NbRatedGameSetup,
@ -253,6 +254,11 @@ object Condition {
minRating: MinRatingSetup,
titled: Boolean
) {
def validRatings = !maxRating.isDefined || !minRating.isDefined || {
maxRating.rating > minRating.rating
}
def convert(perf: PerfType) = All(
nbRatedGame convert perf,
maxRating convert perf,