Skip to content

Commit

Permalink
Add validation rule
Browse files Browse the repository at this point in the history
The "exercises.practice[].status" value must, if "exercises.practice[].slug" is equal to hello-world, be either omitted or the string active

Refs: exercism#249
  • Loading branch information
bobtfish committed Oct 5, 2021
1 parent f79c236 commit 6fb67e1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lint/track_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ proc isValidPracticeExercise(data: JsonNode; context: string;
]
result = allTrue(checks)

if result and data["slug"].getStr() == "hello-world" and data.hasKey("status"):
let statusKey = data["status"].getStr()
if not (statusKey == "active"):
result.setFalseAndPrint(&"The value of {format(context)}.status is `{format(statusKey)}`, but it must be `active` for the hello-world exercise",
path)

proc hasValidExercises(data: JsonNode; path: Path): bool =
const k = "exercises"
if hasObject(data, k, path):
Expand Down

0 comments on commit 6fb67e1

Please sign in to comment.