Skip to content

Type Errors

Type errors occur when a value does not conform to the expected FHIR data type. This includes primitive type format violations (e.g., an invalid date string) and complex type mismatches (e.g., providing a string where an object is expected). Type validation rules are derived from the ElementDefinition.type array in the StructureDefinition.

Primitive Type Errors

These errors occur when a value does not match the format rules for its declared primitive type.

IDSeverityMessage
TYPE_INVALID_BOOLEANerrorValue ‘{value}’ is not a valid boolean
TYPE_INVALID_INTEGERerrorValue ‘{value}’ is not a valid integer
TYPE_INVALID_DECIMALerrorValue ‘{value}’ is not a valid decimal
TYPE_INVALID_STRINGerrorValue must be a string, got {type}
TYPE_INVALID_DATEerrorNot a valid date format: ‘{value}’
TYPE_INVALID_DATETIMEerrorNot a valid dateTime format: ‘{value}’
TYPE_INVALID_TIMEerrorNot a valid time format: ‘{value}’
TYPE_INVALID_INSTANTerrorNot a valid instant format: ‘{value}’
TYPE_INVALID_URIerrorNot a valid URI: ‘{value}’
TYPE_INVALID_URLerrorNot a valid URL: ‘{value}’
TYPE_INVALID_UUIDerrorNot a valid UUID: ‘{value}’
TYPE_INVALID_OIDerrorNot a valid OID: ‘{value}’
TYPE_INVALID_IDerrorNot a valid id: ‘{value}’
TYPE_INVALID_CODEerrorNot a valid code: ‘{value}’
TYPE_INVALID_BASE64errorNot valid base64 content
TYPE_INVALID_POSITIVE_INTerrorValue ‘{value}’ must be a positive integer (>0)
TYPE_INVALID_UNSIGNED_INTerrorValue ‘{value}’ must be a non-negative integer (>=0)
TYPE_STRING_TOO_LONGwarningString length {count} exceeds maximum {max}

Complex Type Errors

These errors occur when the type of an element does not match what the StructureDefinition allows.

IDSeverityMessage
TYPE_WRONG_TYPEerrorElement ‘{path}’ has wrong type. Expected {expected}, got {type}
TYPE_NOT_ALLOWEDerrorType ‘{type}’ is not allowed for element ‘{path}’
TYPE_CHOICE_INVALIDerrorCannot determine type for choice element ‘{path}’

Primitive Type Details

TYPE_INVALID_BOOLEAN

FHIR booleans must be the JSON literal values true or false. Strings like "true" or numbers like 1 are not valid.

{
  "resourceType": "Patient",
  "active": "yes"
}

Fix: Use the JSON boolean literal:

{
  "resourceType": "Patient",
  "active": true
}

TYPE_INVALID_INTEGER

FHIR integers must be JSON numbers with no fractional component. The valid range is -2,147,483,648 to 2,147,483,647 (32-bit signed integer).

{
  "resourceType": "RiskAssessment",
  "prediction": [
    {
      "relativeRisk": "three"
    }
  ]
}

TYPE_INVALID_DECIMAL

FHIR decimals must be valid JSON numbers or strings representing decimal values. Scientific notation is not permitted.

{
  "resourceType": "Observation",
  "valueQuantity": {
    "value": "1.5e2"
  }
}

TYPE_INVALID_DATE

FHIR dates must match the format YYYY, YYYY-MM, or YYYY-MM-DD.

{
  "resourceType": "Patient",
  "birthDate": "01/15/1990"
}

Fix:

{
  "resourceType": "Patient",
  "birthDate": "1990-01-15"
}

TYPE_INVALID_DATETIME

FHIR dateTime values must match one of: YYYY, YYYY-MM, YYYY-MM-DD, or YYYY-MM-DDThh:mm:ss+zz:zz. When a time is included, a timezone offset is required.

{
  "resourceType": "Observation",
  "effectiveDateTime": "2024-01-15 10:30:00"
}

Fix:

{
  "resourceType": "Observation",
  "effectiveDateTime": "2024-01-15T10:30:00+00:00"
}

TYPE_INVALID_INSTANT

FHIR instant values must include a full date, time with seconds, and timezone offset: YYYY-MM-DDThh:mm:ss.sss+zz:zz. Unlike dateTime, partial dates are not permitted.

{
  "resourceType": "Bundle",
  "timestamp": "2024-01-15"
}

Fix:

{
  "resourceType": "Bundle",
  "timestamp": "2024-01-15T10:30:00.000+00:00"
}

TYPE_INVALID_URI

The value must be a syntactically valid URI according to RFC 3986.

TYPE_INVALID_URL

The value must be a syntactically valid URL (a URI that includes a scheme).

TYPE_INVALID_UUID

FHIR UUIDs must match the format urn:uuid: followed by a standard UUID: urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

TYPE_INVALID_OID

FHIR OIDs must match the format urn:oid: followed by a valid OID: urn:oid:1.2.3.4.5.

TYPE_INVALID_ID

FHIR id values must match the regex [A-Za-z0-9\-\.]{1,64}.

{
  "resourceType": "Patient",
  "id": "patient id with spaces!"
}

Fix:

{
  "resourceType": "Patient",
  "id": "patient-123"
}

TYPE_INVALID_CODE

FHIR code values must match the regex [^\s]+(\s[^\s]+)*. They cannot have leading or trailing whitespace, and cannot contain consecutive whitespace characters.

TYPE_INVALID_BASE64

The value is not valid base64-encoded content. FHIR base64Binary values must contain only valid base64 characters (A-Z, a-z, 0-9, +, /) with optional padding (=).

TYPE_INVALID_POSITIVE_INT

FHIR positiveInt values must be integers greater than zero (> 0).

{
  "resourceType": "Timing",
  "repeat": {
    "count": 0
  }
}

TYPE_INVALID_UNSIGNED_INT

FHIR unsignedInt values must be integers greater than or equal to zero (>= 0).

TYPE_STRING_TOO_LONG

The string value exceeds the maximum length for the data type. The FHIR string type has a maximum length of 1,048,576 characters (1 MB). This is a warning rather than an error.


Complex Type Details

TYPE_WRONG_TYPE

The JSON type of the value does not match what the ElementDefinition declares. For example, a string was found where an object (complex type) was expected.

{
  "resourceType": "Patient",
  "name": "John Smith"
}

Patient.name expects an array of HumanName objects, not a string.

Fix:

{
  "resourceType": "Patient",
  "name": [
    {
      "text": "John Smith"
    }
  ]
}

TYPE_NOT_ALLOWED

The type used for a polymorphic (choice) element is not among the types permitted by the ElementDefinition.

{
  "resourceType": "Observation",
  "valueAddress": {
    "city": "Boston"
  }
}

If the profile only allows valueQuantity, valueString, or valueCodeableConcept, then valueAddress is not permitted.

TYPE_CHOICE_INVALID

A choice element (e.g., value[x]) was provided but the validator cannot determine which type was intended. This can happen when the suffix does not match any allowed type name.

Choice elements in FHIR use the pattern elementName[x], where [x] is replaced with the type name in PascalCase. For example, valueString, valueQuantity, valueCodeableConcept. The allowed types are listed in ElementDefinition.type for that element.
Last updated on