better validate tournament rating condition form
This commit is contained in:
parent
34940348ec
commit
010db29a36
|
@ -77,6 +77,7 @@ moreJs = moreJs) {
|
|||
</table>
|
||||
<fieldset class="conditions">
|
||||
<legend> Advanced settings </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.
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue