Validation Flags

Validation Flags

Fine-grained control over validation behavior using flags in your _config exports.

Available Flags

$showErrorMessage

Controls whether detailed validation errors are shown to the client.

$showErrorMessage: true  // Show detailed errors
$showErrorMessage: false // Show generic errors
ts

Recommended: true in development, false in production for security.

$skipValidation

Skip validation for a specific schema while still documenting it.

$skipValidation: true  // Skip validation
$skipValidation: false // Enable validation (default)
ts

Usage

Apply flags to any validation property:

export const _config = {
  openapiOverride: {
    POST: {
      $headers: {
        $showErrorMessage: import.meta.env.DEV,
        $skipValidation: false,
        schema: z.object({ ... }).toJSONSchema(),
      },
      requestBody: {
        content: {
          "application/json": {
            $showErrorMessage: true,
            schema: z.object({ ... }).toJSONSchema(),
          },
        },
      },
    },
  },
} satisfies RouteConfig;
ts

See Also