Guards Reference
QWED-UCP includes 6 verification guards that validate different aspects of UCP checkout data.1. Money Guard
Verifies the total formula is mathematically correct.Usage
Tolerance
UsesDecimal precision with 1 cent ($0.01) tolerance for floating-point errors.
2. State Guard
Verifies valid checkout state machine transitions.Valid States
Usage
Rules
incomplete: Can be emptyready_for_complete: Must have line itemscompleted: Must have order object- Cannot transition backwards
3. Schema Guard
Validates UCP JSON schema compliance.Usage
Validates
- Required fields present
- Correct types (string, number, array)
- Valid enum values (status, total types)
4. Line Items Guard
Verifies price × quantity = line total for each item.Usage
Checks
- Each item:
price × quantity = line_total - Sum of line items = subtotal
- Quantities must be positive integers
- Prices must be non-negative
5. Discount Guard
Verifies percentage and fixed discount calculations.Usage - Percentage Discount
Usage - Fixed Discount
Rules
- Percentage: Must be 0-100%
- Fixed: Cannot exceed subtotal
- Discount must be non-negative
6. Currency Guard
Validates ISO 4217 currency codes and format.Usage
Validates
- 3-letter ISO 4217 codes (USD, EUR, GBP, JPY, etc.)
- Zero-decimal currencies (JPY, KRW) have no decimals
- Currency conversion accuracy
Zero-Decimal Currencies
Running All Guards
UseUCPVerifier to run all guards at once: