A. srv / valida.php

1<?php
2
3require_once __DIR__ . "/../lib/php/ejecutaServicio.php";
4require_once __DIR__ . "/../lib/php/ProblemDetails.php";
5require_once __DIR__ . "/../lib/php/leeTexto.php";
6
7ejecutaServicio(function () {
8 $saludo = leeTexto("saludo");
9 $nombre = leeTexto("nombre");
10 if (
11 $saludo === null
12 || $saludo === ""
13 ) {
14 throw new ProblemDetails(
15 status: ProblemDetails::BadRequest,
16 type: "/error/faltasaludo.html",
17 title: "Falta el saludo.",
18 );
19 }
20 if (
21 $nombre === null
22 || $nombre === ""
23 ) {
24 throw new ProblemDetails(
25 status: ProblemDetails::BadRequest,
26 type: "/error/faltanombre.html",
27 title: "Falta el nombre.",
28 );
29 }
30 $resultado =
31 "{$saludo} {$nombre}.";
32 return $resultado;
33});
34
skip_previous skip_next