CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/aspnet-error-handling

Error handling for ASP.NET Core APIs — exception middleware, ProblemDetails,

94

1.13x
Quality

90%

Does it follow best practices?

Impact

100%

1.13x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-4/

Patient Registration API — Validation Error Standardisation

Problem Description

A healthcare SaaS company is integrating their patient registration API with several hospital information systems (HIS). The HIS vendors have all implemented clients that understand RFC 7807 Problem Details responses — they look for the errors dictionary inside the response body to display field-level validation messages to clinical staff (e.g. "Date of birth is required", "NHS number must be 10 digits").

The problem: the current API uses the default ASP.NET Core model validation behaviour, which returns a response shaped differently from the structured error format the exception handler produces. When a nurse submits a form with a missing required field, the mobile terminal shows a parsing error instead of the specific field message. The HIS integration team has explicitly asked that validation failures use the same RFC 7807 format as all other errors, with a consistent title and the errors map populated with field names and messages.

The API uses Data Annotations ([Required], [MaxLength], [RegularExpression]) on its request models. You do not need to switch validation libraries — just ensure the response format matches what the HIS clients expect.

Output Specification

Produce the following files in your working directory:

  • Program.cs — startup configuration including the validation error response customisation
  • PatientRegistrationRequest.cs — a request model with at least four fields using data annotation validation attributes
  • PatientsController.cs — a controller with a POST endpoint at /api/patients that accepts the request model
  • validation_design.md — a short explanation (3–5 sentences) of how the validation response is shaped, what the title field contains, and which Content-Type is returned

Do NOT add manual validation logic inside the controller action — rely on ASP.NET Core's automatic model validation.

evals

tile.json