summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-17 19:12:10 +0200
committermo8it <mo8it@proton.me>2024-04-17 19:12:10 +0200
commitd6bb27ec2060863c38794b7c2511ca7399e29172 (patch)
tree7b654b86a58020083251648d4d3942e9d00e9997
parentd42a6e741564313460fceb055d0aebe599cbe232 (diff)
Check for empty field values
-rw-r--r--src/dev/check.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/dev/check.rs b/src/dev/check.rs
index 2c48f0e..3cb5345 100644
--- a/src/dev/check.rs
+++ b/src/dev/check.rs
@@ -19,6 +19,9 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result<hashbrown::HashSet<
let mut paths = hashbrown::HashSet::with_capacity(info_file.exercises.len());
for exercise_info in &info_file.exercises {
+ if exercise_info.name.is_empty() {
+ bail!("Found an empty exercise name in `info.toml`");
+ }
if let Some(c) = forbidden_char(&exercise_info.name) {
bail!(
"Char `{c}` in the exercise name `{}` is not allowed",
@@ -27,11 +30,18 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result<hashbrown::HashSet<
}
if let Some(dir) = &exercise_info.dir {
+ if dir.is_empty() {
+ bail!("Found an empty dir name in `info.toml`");
+ }
if let Some(c) = forbidden_char(dir) {
bail!("Char `{c}` in the exercise dir `{dir}` is not allowed");
}
}
+ if exercise_info.hint.is_empty() {
+ bail!("The exercise `{}` has an empty hint. Please provide a hint or at least tell the user why a hint isn't needed for this exercise", exercise_info.name);
+ }
+
if !names.insert(exercise_info.name.as_str()) {
bail!(
"The exercise name {} is duplicated. Exercise names must all be unique",