| 1 | <?php |
| 2 | |
| 3 | require_once __DIR__ . "/../lib/php/BAD_REQUEST.php"; |
| 4 | require_once __DIR__ . "/../lib/php/ProblemDetails.php"; |
| 5 | |
| 6 | function validaCantidad(false|null|float $cantidad) |
| 7 | { |
| 8 | if ($cantidad === false) |
| 9 | throw new ProblemDetails( |
| 10 | status: BAD_REQUEST, |
| 11 | title: "Falta la cantidad.", |
| 12 | type: "/error/faltacantidad.html", |
| 13 | detail: "La solicitud no tiene el valor de cantidad." |
| 14 | ); |
| 15 | |
| 16 | if ($cantidad === null) |
| 17 | throw new ProblemDetails( |
| 18 | status: BAD_REQUEST, |
| 19 | title: "Falta la cantidad.", |
| 20 | type: "/error/cantidadenblanco.html", |
| 21 | detail: "Pon un número en el campo cantidad." |
| 22 | ); |
| 23 | |
| 24 | return $cantidad; |
| 25 | } |
| 26 | |