Missing Field vs Null Field: Two Different Failures

“Field not found” and “Field is null” may both appear as blank on the user interface, but they should not be treated as equivalent once the program is executed.

If you build tools that read values from documents, you may have seen a blank field and assumed it means the same thing every time. In a user interface, "field not found" and "field is null" can both look empty. Once your program runs, though, they are different results and should be handled differently.

This guide is for developers and data editors who pass extracted figures to other systems. The main risk is replacing a blank with the number zero. Downstream systems then receive a valid numerical value and may assume it came from the original source, which can hide a real extraction problem.

You will see how to separate three states, how to check them with JSON Schema, and how to show each state clearly in an interface before data moves on.

Note: The examples in this guide use synthetic samples and were checked in an isolated environment. They do not guarantee results for every real-world file or product. Keep the original copies of important files, and verify your output against your own boundaries and acceptance criteria.

How do you tell a missing field from a null field? The short answer

Treat a missing key, a null value, and a zero as three separate states, and check each one against your contract before the data moves on.

Your situationWhat to doWhy
The amount key is absentReport it as an output contract exceptionThe output structure is incomplete, so it is not the same as zero
amount exists and is nullTreat it as a value that has not been assignedIt means no funds are currently available, not a successful extraction
amount is 0Read it as a specific numeric valueZero is a real, well-defined number
amount is an unrecognised stringReject it as non-compliantIt should not pass silently after being converted to null

The three states you need to separate

In the contract used in this guide, amount must always exist. Its value may be a number or null. Each state means something different:

  • Key absent: the output structure is incomplete.
  • Key present, value null: no funds are currently available.
  • Key present, value 0: a specific numerical value, namely zero.

Other protocols may be used in real business settings. If you choose one, document it clearly, so that each caller does not have to guess what a blank means.

Why blanks become a problem

  • A blank shown in the interface does not reveal which state it is.
  • Replacing a blank with 0 creates a valid number that looks like a real figure.
  • Downstream systems cannot tell whether that number came from the source or from a default.

Checking the contract with JSON Schema

JSON Schema helps you check these states automatically. Two keywords do different jobs:

  • required checks whether the key exists.
  • type checks the type of the value.

Two common misconceptions are worth testing directly in your regression suite:

  • Using required alone does not stop a value from being null. You need type to allow or reject null.
  • Listing a field under properties does not make it mandatory. It still does not have to appear unless required names it.

For a full reference, see JSON Schema object and required.

Running the four-input check

The example below runs four inputs against the contract:

from jsonschema import Draft202012Validator

schema = {"type": "object", "required": ["amount"],
          "properties": {"amount": {"type": ["number", "null"]}},
          "additionalProperties": False}
validator = Draft202012Validator(schema)
valid = lambda value: not list(validator.iter_errors(value))

assert valid({"amount": None})
assert valid({"amount": 0})
assert not valid({})
assert not valid({"amount": "unknown"})
assert not valid({"amount": None, "guessed": True})

To run it, install jsonschema. The code performs structural checks in memory. It does not call an extraction model, and it does not prove that any amount matches the original text.

A note on decimal amounts

The example uses number, which relies on binary floating-point arithmetic. If you need exact decimal values for money, consider a separate decimal string protocol instead. Do not use number for financial calculations simply because the example does.

Showing each state clearly in the interface

Your interface must also make the status visible. Each data state should be shown as what it is, not as something it is not:

DataThe state that should be shownWhat it should not be shown as
No amount keyOutput contract exceptionAmount is zero
amount is nullHas not been assigned a valid valueExtraction successful
amount is 0Has a well-defined zero valueMissing
amount is an unrecognised stringDoes not comply with this contractSilently passes after being converted to null

Keep reasons out of numeric fields

Sometimes you need to know why a value is missing. For example, the figure may not be in the original text, the image may be unreadable, or two candidate values may conflict. Handle this with separate fields:

  • Add a status or reason field.
  • Define its allowed values in your schema.
  • Do not put the reason inside an amount string. If you do, downstream systems have to extract numbers from text, which is fragile.

Unknown is not the same as failure. Some documents simply do not contain a given field. In that case, the correct result is to keep it as unknown.

Checks before you pass data on

Once the structure passes validation, you still need to check the amount itself, its source, and its tags. This matters most when you combine translation with extraction. The checks below can work as a post-translation checklist, helping you confirm that key figures were not changed by accident:

  1. Confirm the currency of each amount.
  2. Confirm where each amount came from in the source.
  3. Confirm the tags attached to each amount.
  4. Compare key figures against the original document.

This checklist supports a review of the original text. It does not replace that review.

This guide does not claim that OmniDoc (product entry point) uses this schema internally. Valid JSON also does not mean the extraction is accurate.

📊 At a glance

CaseStructure checkValue shown in interfaceDownstream treatment
Key absentFails requiredOutput contract exceptionReport as incomplete output
Value nullPasses only if type allows nullNot assigned a valid valueDo not treat as successful extraction
Value 0Passes as a numberWell-defined zeroUse as a numeric value
Unrecognised stringFails typeNon-compliant with contractReject, do not convert to null

🎯 Which approach fits you?

If you pass extracted figures to other systems

Check all three states separately, so a blank never turns into a zero.

If you use required and assume that covers null

Add a type rule that controls whether null is allowed, and test both cases.

If you need to explain why a value is missing

Add a status or reason field with defined allowed values, and keep the amount field numeric.

❓ FAQ

1. Is a missing key the same as a null value?

No. A missing key means the output structure is incomplete. A null value means the key is present but has no valid value assigned.

2. Does required stop a field from being null?

No. required only checks that the key exists. Use type to control whether null is allowed.

3. Should I replace a blank amount with zero?

No. Zero is a real numerical value, so using it for a blank can make a missing figure look like a confirmed one.

4. Does passing schema validation mean my extraction is accurate?

No. The check runs structurally in memory and does not prove that any amount matches the original text.

📝 Summary

Missing keys, null values, and zeros are three different states, and each should be shown and handled as such. Check them with JSON Schema, keep reasons in separate fields, and verify key figures against the original document.

Try it now: upload a document and get it translated with the layout intact

Updated 2026-11-04