Skip to content

Commit

Permalink
Improve validation
Browse files Browse the repository at this point in the history
null values could produce server errors.
  • Loading branch information
mzur committed Nov 28, 2024
1 parent 4b7da60 commit 89217e5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Annotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public static function validate(array $data): void
if (!array_key_exists($key, $data)) {
throw new \Exception("Missing key '$key' in Annotation");
}

if (is_null($data[$key])) {
throw new \Exception("Missing value for '$key' in Category");
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public static function validate(array $data): void
if (!array_key_exists($key, $data)) {
throw new \Exception("Missing key '$key' in Category");
}

if (is_null($data[$key])) {
throw new \Exception("Missing value for '$key' in Category");
}
}
}
}
4 changes: 4 additions & 0 deletions src/Coco.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public static function validate(array $data): void
if (!array_key_exists($key, $data)) {
throw new \Exception("Missing key '$key' in Coco");
}

if (is_null($data[$key])) {
throw new \Exception("Missing value for '$key' in Coco");
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public static function validate(array $data): void
if (!array_key_exists($key, $data)) {
throw new \Exception("Missing key '$key' in Image");
}

if (is_null($data[$key])) {
throw new \Exception("Missing value for '$key' in Image");
}
}
}
}

0 comments on commit 89217e5

Please sign in to comment.