Problem statement
Build a REST API for submitting passport application forms with validation and a minimum age check.
PassportApplicationRequest
Enforce the constraints below on each field. Every broken constraint returns 400 Bad Request with the exact message shown.
fullName field:
- Must not be missing, empty, or whitespace-only
- When it is blank, show message: "Full name must not be blank"
- Must be at most 80 characters long; a name of exactly 80 characters is accepted
- When it is longer than 80 characters, show message: "Full name must be at most 80 characters"
dateOfBirth field:
- Must not be missing
- When it is missing, show message: "Date of birth is required"
- Must be a date earlier than the current date
- When it is today or any later date, show message: "Date of birth must be in the past"
placeOfBirth field:
- Must not be missing, empty, or whitespace-only
- When it is blank, show message: "Place of birth must not be blank"
ApplicationController
Implement the single REST endpoint at exactly the verb and path shown.
POST /applications
- Accept a JSON body with fullName, dateOfBirth, and placeOfBirth and validate it against the field constraints above; dateOfBirth is sent and returned as an ISO date, for example 2000-05-14
- If dateOfBirth lies in the past but the applicant has not yet reached 18 years of age, measured against the current date on the server, return 400 Bad Request with error message: "Applicant must be at least 18 years old"
- An applicant who turns exactly 18 on the current date is old enough, and so is anyone older
- On a valid submission, return 200 OK with a body carrying status with the value ACCEPTED together with the submitted fullName, dateOfBirth, and placeOfBirth
Sample Requests & Responses
Expand to view details on sample requests and responses.
POST /applications
Request:
{
"fullName": "Amelia Rose Hartley",
"dateOfBirth": "1994-03-12",
"placeOfBirth": "Wellington"
}
Response (200 OK):
{
"status": "ACCEPTED",
"fullName": "Amelia Rose Hartley",
"dateOfBirth": "1994-03-12",
"placeOfBirth": "Wellington"
}
POST /applications
Request:
{
"fullName": "",
"dateOfBirth": "1994-03-12",
"placeOfBirth": "Wellington"
}
Response (400 Bad Request):
{
"error": "Full name must not be blank",
"timestamp": "2026-07-30T09:57:33.665364",
"path": "/applications"
}
POST /applications
Request:
{
"fullName": "Amelia Rose Hartley",
"placeOfBirth": "Wellington"
}
Response (400 Bad Request):
{
"error": "Date of birth is required",
"timestamp": "2026-07-30T09:57:33.683676",
"path": "/applications"
}
POST /applications
Request:
{
"fullName": "Amelia Rose Hartley",
"dateOfBirth": "2031-01-01",
"placeOfBirth": "Wellington"
}
Response (400 Bad Request):
{
"error": "Date of birth must be in the past",
"timestamp": "2026-07-30T09:57:33.693956",
"path": "/applications"
}
POST /applications
Request:
{
"fullName": "Noah James Whitaker",
"dateOfBirth": "2010-05-14",
"placeOfBirth": "Auckland"
}
Response (400 Bad Request):
{
"error": "Applicant must be at least 18 years old",
"timestamp": "2026-07-30T09:57:33.705089",
"path": "/applications"
}
POST /applications
Request:
{
"fullName": "Amelia Rose Hartley",
"dateOfBirth": "1994-03-12",
"placeOfBirth": " "
}
Response (400 Bad Request):
{
"error": "Place of birth must not be blank",
"timestamp": "2026-07-30T09:57:33.721387",
"path": "/applications"
}
