October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Handle Validation Errors and Type Coercion in Aontu

Learn how to read Aontu vet findings and why fixed-scale exact decimals should cross JSON as constrained strings, not parsed numbers.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run aontu vet schema.aon data.json, then use the reported data path and finding to identify what disagrees with the schema. For the documented exact-decimal case, Aontu rejects a JSON number when the schema expects bigdecimal rather than silently coercing a value that may already have lost precision during JSON parsing. Carry fixed-scale decimals as constrained strings and parse them into an exact decimal type only after validation.

Run validation and locate the failure

The Aontu guide demonstrates vetting a data file against a schema with aontu vet invoice.aon invoice.json. A successful check prints verdict: valid. Rejected data prints verdict: invalid, followed by a finding that identifies a path such as $.invoice.total, a finding category, and the relevant data and schema details. The guide’s shell example returns exit status 1 for invalid data. Aontu describes the purpose of the tool as combining data, schemas, and defaults into a consistent result or reporting where they conflict (Aontu package documentation).

As an Amazon Associate I earn from qualifying purchases.

  1. Run aontu vet schema.aon data.json, substituting your schema and data filenames.
  2. Read the reported path first. Use it to find the specific value in the input document.
  3. Compare the actual value and the schema details shown in the finding. Determine whether the conflict is about the value’s type or scalar, or whether it violates a constraint.
  4. Correct the data or schema deliberately, then run the same command again to confirm the result.

Do not respond to every failure by converting the value. A conversion can change its meaning, and the finding tells you what property actually failed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Distinguish a type mismatch from a constraint failure

The guide demonstrates two different failures. A JSON number supplied where the schema requires bigdecimal produces a scalar-unification conflict, shown in the example as no_scalar_unify. A string can satisfy a string type and still fail a constraint: in the guide’s two-decimal example, "19.9" is text but does not match the required scale pattern.

  • Type or scalar-unification conflict: the value does not meet the schema’s required type or scalar, as with the demonstrated JSON number and bigdecimal.
  • Constraint failure: the value has the expected type but fails an additional rule, as with the one-decimal string against a two-decimal pattern.

These are examples, not a complete catalog of Aontu finding categories. Follow the specific finding and expected-versus-actual details printed for your data.

Why the documented JSON number is not coerced to an exact decimal

In the official example, the JSON parser has already represented a number as a binary64 floating-point value by the time Aontu validates it. That representation may no longer preserve the exact decimal digits originally written in the JSON. Aontu therefore rejects the value when the schema requires bigdecimal, rather than certifying a potentially altered decimal as exact. The Aontu guide calls this refusal a feature: a schema should not admit a value after the wire representation has already lost the exactness the schema promises.

This explains the documented JSON-number-to-bigdecimal path; it is not a complete coercion policy for every Aontu type or input format. The available guide does not establish that all Aontu mismatches are handled this way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Represent fixed-scale decimals as constrained JSON strings

For an exact fixed-scale decimal crossing JSON, send the digits as a JSON string, for example "19.99", instead of as the number 19.99. In the schema, require both type: string and a regular-expression constraint for the intended decimal form and scale. The type restriction rejects a bare JSON number; the pattern can reject malformed text or a string with the wrong number of fractional digits. In the guide’s example, "19.99" passes the two-decimal pattern and "19.9" does not.

The guide also shows a fuller pattern: define a reusable decimal-string type, package the amount with its currency, and use an optional constant conversion mark such as bigdecimal:2 to identify the leaf and intended scale. Making the mark constant prevents the data from substituting a different conversion preference, such as float. After validation succeeds, parse the string with an exact decimal implementation; the guide names TypeScript’s Decimal class and Go’s math/big as examples. Do not use parseFloat when exact decimal arithmetic is required.

Choose the JSON representation based on what must be preserved

Representation Exact decimal digits Type and scale checks Consumer handling
JSON number In the documented Aontu case, parsing may convert it to binary64 and lose exact decimal representation. It does not satisfy the demonstrated exact bigdecimal schema. Aontu rejects that documented mismatch instead of coercing it into an exact decimal.
Constrained decimal string Carries the decimal digits as text across the JSON boundary. A string type check rejects non-strings; a pattern can enforce the required scale and spelling. Validate first, then parse with an exact decimal implementation.

Use a JSON number when the value is ordinary numeric data and exact decimal spelling is not the contract. Use a constrained string when the digits and fixed scale are part of the contract, as in the guide’s money example.

Keep currency and display scale explicit

A decimal value alone does not necessarily retain the original number of fractional digits. The guide notes that 0d10.50 and 0d10.5 are equal values and that canonical output uses the shorter representation. If an application must display two fractional digits, format the validated amount using its declared scale; do not expect the numeric value to reveal whether the input originally ended in zero. For monetary data, keep the currency alongside the amount so the amount’s unit is part of the data contract.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Implementation scope

Aontu’s package documentation describes TypeScript as its canonical implementation and Go as a port that mirrors core unification semantics (Aontu package documentation). The Go API material names verdicts valid, invalid, incomplete, and error (Go API documentation). Those verdict labels do not establish that every diagnostic string or detail is identical across TypeScript and Go releases. Consult the documentation for the implementation and version you use when relying on details beyond the demonstrated examples.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.