test-cases
Numeric Schema Type Contract
Verify numeric YAML scalar typing and the distinction between integer formatting controls and lexical ordinal values across a real workspace check and inspect flow.
Purpose
Verify that Forma validates YAML numeric scalars through the same workspace discovery, check, and inspect paths used by real workspaces. Numeric strings must not be coerced implicitly, while lexical zero-padded values must remain strings.
Real-world Use Case
Arcadia Library now uses ordinalWidth: 2 as an unquoted YAML integer in its structure index and keeps generated ordinals such as "01" as strings. Its workspace validator additionally requires ordinalWidth to be positive. This fixture records the Forma-side contract: integer validates the YAML scalar and integrality, string preserves lexical formatting, and the positive-integer rule remains workspace-specific because P0 has no range constraints.
Test Data
- Workspace fixture:
crates/forma-core/tests/fixtures/numeric-schema - Automated test:
cargo test -p forma-cli --test cli numeric_schema_fixture_checks_yaml_scalar_types -- --nocapture
Steps
- Run the automated test from the repository root.
- Confirm the fixture's unquoted
ratio: 1.5,count: -2, andordinalWidth: 2values passforma check --json. - Confirm
forma inspect measurements/reading.md --jsonpreserves numeric JSON values, numericordinalWidth: 2, and lexicalordinal: "01". - Confirm a copied fixture with
count: "2"fails withschema.type.invalidat thecountfield. - Confirm a copied fixture with
ordinalWidth: "2"fails withschema.type.invalidat theordinalWidthfield.
Expected Results
- Unquoted YAML numbers satisfy
type: numberandtype: integeras applicable. - Quoted numbers fail numeric Schema validation instead of being coerced.
- Numeric formatting controls such as
ordinalWidthremain numbers, while zero-padded ordinal values remain strings. - Positivity for
ordinalWidthis a workspace-validator rule, not a P0integerconstraint. - The same diagnostics and values are observable through the CLI workspace contract.
Coverage
- YAML numeric scalar typing.
numberandintegerSchema primitives.- Workspace discovery and
checkvalidation. - CLI
inspectmetadata preservation. - Numeric configuration versus lexical-format metadata.