$missing, ]); } } function v2_validate_enum(string $value, array $allowed, string $fieldName): void { if (!in_array($value, $allowed, true)) { v2_response_error(400, 'invalid_value', "Ungültiger Wert für '$fieldName'.", [ 'allowed' => $allowed, 'got' => $value, ]); } } function v2_validate_int_range(int $value, int $min, int $max, string $fieldName): void { if ($value < $min || $value > $max) { v2_response_error(400, 'out_of_range', "Wert für '$fieldName' außerhalb [$min,$max]."); } } function v2_validate_method(string $expected): void { $actual = $_SERVER['REQUEST_METHOD'] ?? ''; if ($actual !== $expected) { v2_response_error(405, 'method_not_allowed', "Methode $actual nicht erlaubt, erwartet $expected."); } } function v2_validate_method_in(array $expected): string { $actual = $_SERVER['REQUEST_METHOD'] ?? ''; if (!in_array($actual, $expected, true)) { v2_response_error(405, 'method_not_allowed', "Methode $actual nicht erlaubt."); } return $actual; }