Skip to content

Commit

Permalink
disallow more than one contact being marked as primary
Browse files Browse the repository at this point in the history
closes #368
  • Loading branch information
Foxcapades committed Feb 10, 2025
1 parent 20ece82 commit f1790a7
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@ internal fun DatasetPostMeta.validate(validationErrors: ValidationErrors) {

publications.forEachIndexed { i, pub -> pub.validate("meta.", i, validationErrors) }
hyperlinks.forEachIndexed { i, link -> link.validate("meta.", i, validationErrors) }
contacts.forEachIndexed { i, con -> con.validate("meta.", i, validationErrors) }

var primaries = 0
contacts.forEachIndexed { i, con ->
con.validate("meta.", i, validationErrors)
if (con.isPrimary == true)
primaries++
}
if (primaries > 1)
validationErrors.add("meta.contacts", "only one contact may be marked as primary")

organisms.forEachIndexed { i, l ->
if (l == null)
validationErrors.add("meta.organisms[$i]", "entries must not be null")
Expand Down

0 comments on commit f1790a7

Please sign in to comment.