Validation Errors
Validation errors (HTTP 400 Bad Request) occur when a request does not meet the expected format — missing required fields, values that are out of range, incorrect data types, or an unsupported content type. This page explains the validation layers in PrimeCalendar and how to diagnose each type.
Understanding the validation response
When PrimeCalendar's API rejects a request due to validation failure, the response body includes structured detail:
{
"statusCode": 400,
"message": ["title must not be empty", "startAt must be a valid ISO 8601 date string"],
"error": "Bad Request"
}
The message array lists each validation failure. If only one field failed, it may be a string instead of an array.
Missing or empty required field
Example error: "title must not be empty" or "startAt should not be empty"
Why it happens: The NestJS validation pipe uses class-validator decorators on DTO classes. Fields marked @IsNotEmpty() or @IsString() reject empty strings and null values.
Fix (users): Fill in all required fields in the form. Required fields are typically marked with an asterisk in the UI.
Fix (developers): Check the DTO definition for the endpoint. Ensure the frontend sends all fields the backend expects. The frontend validation in form components should catch these before the request is sent.
Invalid date format
Example error: "startAt must be a valid ISO 8601 date string"
Why it happens: Event dates must be sent as ISO 8601 strings (e.g., "2026-06-30T14:00:00.000Z"). If the frontend sends a different format — or sends a Date object that was not serialized — the backend rejects it.
Fix: Ensure the frontend formats dates with .toISOString() before including them in request payloads.
Unsupported content type
What you see: HTTP 415 Unsupported Media Type
Why it happens: The backend's RequestHardeningMiddleware validates the Content-Type header on POST/PUT/PATCH requests. Requests without Content-Type: application/json (or multipart/form-data for file uploads) are rejected.
Fix: Include the correct Content-Type header. Most frameworks set this automatically for JSON requests, but curl and custom integrations must set it explicitly:
curl -X POST ... -H "Content-Type: application/json" -d '{"key":"value"}'
Request body too large for JSON parsing
What you see: HTTP 400 with a message about the body size or JSON parse failure.
Why it happens: The RequestHardeningMiddleware enforces a maximum body size before JSON parsing. Requests slightly over the limit may fail at the JSON parser rather than returning 413.
Fix: Reduce the size of the request body. If you are sending large data (e.g., a large event description), split it or compress it.
Invalid timezone value
What you see: HTTP 400 when saving profile settings with a timezone value.
Why it happens: The backend validates that timezone strings are valid IANA timezone identifiers (e.g., "Europe/Budapest", "America/New_York"). Freeform strings or abbreviated codes like "EST" are rejected.
Fix: Use a value from the supported timezone list in the profile settings dropdown. The list covers 70+ timezones across all continents. Do not type timezone values manually.
Duplicate username or email
What you see: HTTP 409 Conflict (not strictly a 400, but related to input validation)
Why it happens: Changing your username or email to one that already belongs to another user hits a unique constraint at the database level. The backend returns 409 with a message about the conflict.
Fix: Choose a different username or email address. The UI should check availability before submitting in most cases, but timing edge cases can still result in a 409.
Form displays "Invalid value" without submitting
Why it happens: The frontend runs its own client-side validation (often with react-hook-form or custom validators) before sending the request. The field-level error is shown without a network request being made.
Fix: The validation message in the UI describes what is wrong (e.g., "Must be a valid email address", "Cannot be empty"). Correct the value and resubmit.
Still stuck?
- Check the browser Network tab: select the failing request and look at the Response body for the
messagearray. - For developers: the NestJS
ValidationPipeis configured globally. Look at the DTO file for the endpoint to see all validation decorators and understand what is required. - See API Debugging for how to reproduce validation errors with curl or a REST client, bypassing the UI.