Skip to content

Commit 89217e5

Browse files
committed
Improve validation
null values could produce server errors.
1 parent 4b7da60 commit 89217e5

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/Annotation.php

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public static function validate(array $data): void
4040
if (!array_key_exists($key, $data)) {
4141
throw new \Exception("Missing key '$key' in Annotation");
4242
}
43+
44+
if (is_null($data[$key])) {
45+
throw new \Exception("Missing value for '$key' in Category");
46+
}
4347
}
4448
}
4549

src/Category.php

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public static function validate(array $data): void
2626
if (!array_key_exists($key, $data)) {
2727
throw new \Exception("Missing key '$key' in Category");
2828
}
29+
30+
if (is_null($data[$key])) {
31+
throw new \Exception("Missing value for '$key' in Category");
32+
}
2933
}
3034
}
3135
}

src/Coco.php

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public static function validate(array $data): void
7070
if (!array_key_exists($key, $data)) {
7171
throw new \Exception("Missing key '$key' in Coco");
7272
}
73+
74+
if (is_null($data[$key])) {
75+
throw new \Exception("Missing value for '$key' in Coco");
76+
}
7377
}
7478
}
7579

src/Image.php

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public static function validate(array $data): void
3939
if (!array_key_exists($key, $data)) {
4040
throw new \Exception("Missing key '$key' in Image");
4141
}
42+
43+
if (is_null($data[$key])) {
44+
throw new \Exception("Missing value for '$key' in Image");
45+
}
4246
}
4347
}
4448
}

0 commit comments

Comments
 (0)