Fix bug where maxVoters could be 0 while AreVotersKnown was true
This commit is contained in:
@ -26,7 +26,7 @@ func (app *application) createElection(w http.ResponseWriter, r *http.Request) {
|
|||||||
request.CheckField(validator.GreaterThan(len(request.Choices), 1), "choices", "there must be more than 1 choice")
|
request.CheckField(validator.GreaterThan(len(request.Choices), 1), "choices", "there must be more than 1 choice")
|
||||||
|
|
||||||
request.CheckField(
|
request.CheckField(
|
||||||
!(request.AreVotersKnown && request.MaxVoters == nil),
|
!(request.AreVotersKnown && (request.MaxVoters == nil || *request.MaxVoters < 1)),
|
||||||
"maxVoters",
|
"maxVoters",
|
||||||
"must be greater than 0 when voters are known",
|
"must be greater than 0 when voters are known",
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user