FM-001 Data Contracts and Schema Validation

Currency, Number, and Precision Formatting Failures

Numeric values returned in unexpected formats, precisions, or representations — causing incorrect calculations, rounding errors, or financial discrepancies.

Failure explanation

An API exposes a monetary or numeric value using a representation that consumers interpret differently. Common defects include converting decimal amounts to binary floating-point, dropping trailing precision, returning a number as a string unexpectedly, applying locale-specific separators to machine-readable values, or omitting the currency. A value such as 1,234.56 can be misread when a consumer expects a different decimal convention. Monetary values are especially sensitive because rounding errors can accumulate across invoices, balances, taxes, and settlements.

Example

A contract defines:

{ "amount": 10.50, "currency": "USD" }

The implementation returns {"amount":10.5}, or calculates 0.1 + 0.2 and serializes an unexpected value such as 0.30000000000000004.

How to test

  • Validate JSON type, scale, precision, sign, range, and currency presence against the contract.
  • Test very small and large amounts, negative values, zero, rounding boundaries, and currencies with different minor-unit rules.
  • Round-trip values through request, persistence, and response paths.
  • Verify that locale settings do not change machine-readable numeric representations.

Expected behavior

The API preserves the documented numeric representation and precision, applies explicitly defined rounding rules, and identifies the currency where relevant. Report a contract mismatch separately from a business-rule rounding defect.

Runnable examples

Each example includes a broken server, a fixed server, an OpenAPI spec, and a clrsig scenario that detects the failure.