Kaizen
Browse modulesQR codeqr-code/sharedFunctions

Function: parseQrCodeRenderOptions()

function parseQrCodeRenderOptions(options: {
  backgroundColor?: string;
  description?: string;
  minContrastRatio?: number;
  moduleColor?: string;
  size?: number;
  title: string;
}): Required<Omit<{
  backgroundColor?: string;
  description?: string;
  minContrastRatio?: number;
  moduleColor?: string;
  size?: number;
  title: string;
}, "description">> & Pick<{
  backgroundColor?: string;
  description?: string;
  minContrastRatio?: number;
  moduleColor?: string;
  size?: number;
  title: string;
}, "description">;

Defined in: shared/qr-code/svg.ts:129

Validate and normalize render options, applying every invariant both rendering surfaces owe their callers: schema validation (non-empty title, size in range, contrast floor) plus the paint assertions.

Exists because there are two surfaces over one encoder — this string renderer and the UDS QRCode component, which takes props directly and cannot parse a schema on its own. Both call this, so neither can drift on a guarantee. Adding a rule here covers both; adding one to the schema alone would not.

Parameters

ParameterTypeDescription
options{ backgroundColor?: string; description?: string; minContrastRatio?: number; moduleColor?: string; size?: number; title: string; }-
options.backgroundColor?stringPaint for the light modules and quiet zone. Same constraints as moduleColor.
options.description?stringLonger text alternative, rendered as <desc>.
options.minContrastRatio?numberContrast floor enforced between moduleColor and backgroundColor. Can only be raised, not lowered — QR_CODE_MIN_CONTRAST_RATIO is both the default and the floor, since a symbol below it is unreliable to scan regardless of what the caller would prefer.
options.moduleColor?stringPaint for the dark modules. Must be a statically resolvable, fully opaque CSS color — a hex or rgb() literal, black, or white. Design tokens (var(--x)) and currentColor are rejected: their contrast can't be verified, and an unverifiable symbol can't be guaranteed to scan.
options.size?numberRendered width and height in CSS pixels. The SVG scales losslessly.
options.titlestringAccessible name for the image, rendered as <title>. Required: a QR code is a meaningful image, so Section 508 / WCAG 1.1.1 needs a text alternative. Describe the purpose ("Appointment check-in code"), not the payload.

Returns

Required<Omit<{ backgroundColor?: string; description?: string; minContrastRatio?: number; moduleColor?: string; size?: number; title: string; }, "description">> & Pick<{ backgroundColor?: string; description?: string; minContrastRatio?: number; moduleColor?: string; size?: number; title: string; }, "description">

On this page