Every mutating request to theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/mauroperez055/infoJobs/llms.txt
Use this file to discover all available pages before exploring further.
/jobs routes passes through a Zod-based validation layer before reaching the controller. The schema is defined in backend/schemas/jobs.js, which exports two functions — one for full validation on POST and one for partial validation on PATCH. If validation fails, the middleware short-circuits the request and returns a structured 400 response before any business logic runs.
The jobSchema
The schema mirrors the job data model, enforcing types, required fields, and length constraints ontitulo:
Field rules at a glance
| Field | Type | Required | Constraints |
|---|---|---|---|
titulo | string | ✅ | Min 3 chars, max 100 chars |
empresa | string | ✅ | — |
ubicacion | string | ✅ | — |
descripcion | string | ❌ | Optional |
data.technology | string[] | ✅ | Array of technology name strings |
data.modalidad | string | ✅ | e.g. "remoto", "presencial", "hibrido" |
data.nivel | string | ✅ | e.g. "junior", "senior" |
content.description | string | ✅ | Long-form job description |
content.responsibilities | string | ✅ | — |
content.requirements | string | ✅ | — |
content.about | string | ✅ | About the company |
Exported Validation Functions
Both functions calljobSchema.safeParse(), which never throws — it always returns a result object with a success boolean.
validatePartialJob calls .parcial() on the schema (note the spelling used in the source), which makes every top-level field optional. This allows PATCH requests to supply only the fields they want to update without triggering “field required” errors.
Validation Middleware in the Route Layer
backend/routes/jobs.js wires the validation functions into Express middleware functions that run before the controller:
400 Error Response
When a request body fails validation, the middleware immediately returns HTTP400 with a structured error payload. The details array contains one entry per failing field, each with the field path and the human-readable message defined in the schema:
details includes a path array identifying exactly which field failed, making it straightforward for frontend consumers to map errors back to form fields.