Big news: scrolls can now send messages. No need to cross the forest to book a table any more: a magic pigeon takes care of it. It brings a JSON like this one:
{ "nom": "Gimli", "personnes": 3, "jour": "2026-09-18" }
(nom = name, personnes = number of adventurers, jour = day.)
Your mission
- Complete the
ReservationDemandeDTO (reservation request), which describes and validates a request:nom: required (“Enter your name.”);personnes: from 1 to 12 (“The number of adventurers must be between 1 and 12.”);jour: required (“Enter the day of your visit.”), and not in the past (“You cannot book in the past, not even with a magic scroll.”). Today is allowed.
- In
POST /api/reservations, receive the request with#[MapRequestPayload], save aReservation, then respond 201 Created with the reservation (reservationgroup).
Try the three ready-made requests in the Requests tab.
What #[MapRequestPayload] does
Symfony reads the JSON body, fills the DTO, then validates it. Your controller only receives valid requests. Otherwise, Symfony responds for you:
| Problem | Response |
|---|---|
| Unreadable JSON | 400 Bad Request |
Rule broken, missing field, wrong type ("personnes": "three") |
422 Unprocessable Content, with the list of violations |
Why a DTO, and not the entity?
The request is not the reservation. The DTO only contains what the client is allowed to send: no way to slip in an id or a creation date. And the API's validation doesn't depend on the database.