Add more test cases and add UniqueValues check
This commit is contained in:
@ -69,6 +69,11 @@ func isRequestValid(r *createElectionRequestWithValidator) bool {
|
||||
r.CheckField(validator.GreaterThan(r.Tokens, 0), "tokens", "must be greater than 0")
|
||||
r.CheckField(validator.After(r.ExpiresAt, time.Now()), "expiresAt", "must expire in a future date")
|
||||
r.CheckField(validator.GreaterThan(len(r.Choices), 1), "choices", "there must be more than 1 choice")
|
||||
r.CheckField(validator.UniqueValues(r.Choices), "choices", "must not contain duplicate values")
|
||||
|
||||
for _, choice := range r.Choices {
|
||||
r.CheckField(validator.NotBlank(choice), "choice", "must not be blank")
|
||||
}
|
||||
|
||||
if r.AreVotersKnown {
|
||||
r.CheckField(
|
||||
|
Reference in New Issue
Block a user