Validation
Validation checks that a FHIR resource conforms to the specification, a profile, or both. The result is always an OperationOutcome — a structured list of issues with severity, code, and location.
Types of validation
Structural
Is the JSON (or XML) syntactically valid? Does it have a resourceType? Are all required fields present as defined by the base FHIR spec? Is the data type correct — is a date field actually a date?
Always the first check. If structure is broken, further validation stops.
Cardinality
Do elements appear the correct number of times? If a profile says identifier must have at least 1 entry (1..*), does the resource provide at least one?
Applied against base spec + any active profiles.
Terminology
Are coded values from the correct CodeSystem? If gender must be from AdministrativeGender, is the value one of male/female/other/unknown? Does a LOINC code exist in the LOINC CodeSystem?
Requires access to terminology services. May be skipped in lightweight validators.
Profile conformance
Does the resource meet all constraints defined in a StructureDefinition — cardinality, mustSupport, fixedValues, slicing rules, and invariants?
Only when a profile is specified, either via meta.profile[] or via the ?profile= query parameter.
Business rules (invariants)
FHIRPath expressions defined in the spec that enforce cross-field logic. Example: Observation must have either value[x] or dataAbsentReason — not neither. dom-6: resources should have narrative text.
Applied against base spec invariants always. Profile invariants when profiling is active.
OperationOutcome
Every FHIR validation result is an OperationOutcome resource — a list of issues. Each issue has a severity, a code, a human-readable diagnostics message, and optionally an expression path pointing to the exact element that caused the issue.
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "required",
"diagnostics": "Patient.gender: minimum required = 1, but only found 0",
"expression": ["Patient.gender"]
},
{
"severity": "warning",
"code": "best-practice",
"diagnostics": "dom-6: A resource should have narrative for robust management"
}
]
}The $validate operation
FHIR servers expose a $validate operation that validates a resource without storing it. You POST the resource and get back an OperationOutcome.
Our validation results
We validated Jana Horváth (examples/patients/jana-horvath.json) against the FhirSkPatient profile using HAPI FHIR:
1 warning only: dom-6 (no narrative text). All cardinality constraints satisfied. Profile compliant.
4 errors: identifier missing, gender missing, birthDate missing, name.given missing.
Try both in the Validator — use "Load valid" and "Load invalid" buttons.