Skip to main content

Value Constraints

This subsection consists of extensions related to value constraints and form validation.

The elements/extensions that fall under this subsection are:

From Core Questionnaire

From SDC

tip

Elements/extensions in this subsection invokes form validation in the renderer. OperationOutcome resources are generated when the current state of the form does not meet the constraints defined in the Questionnaire.

For more information, refer to the InvalidItems section in Developer Usage.

Required​

An indication, if true, that the item must be present in a "completed" QuestionnaireResponse. If false, the item may be skipped when answering the questionnaire.

Also appears in the Fundamental Elements subsection.

Basic Usage​

MaxLength​

The maximum length of the string value of the answer to this question.

MaxLength is only supported on decimal, integer, string and text "text-field"-based items.

Basic Usage​

MinLength​

The minimum length of the string value of the answer to this question.

MinLength is only supported on decimal, integer, string and text "text-field"-based items.

Basic Usage​

Regex​

A regular expression constraint for the string value of the answer to this question.

Regex is only supported on decimal, integer, string and text "text-field"-based items.

tip

"regex" extension doesn't allow you to customise error messages. It is recommended to use targetConstraint instead.

Basic Usage​

MinValue​

The minimum value of the quantifiable answer to this question.

MinValue is only supported on decimal, integer, date and dateTime items.

Basic Usage​

MaxValue​

The maximum value of the quantifiable answer to this question.

MinValue is only supported on decimal, integer, date and dateTime items.

Basic Usage​

MinQuantity​

The minimum value of the quantifiable valueQuantity.value to this question.

MinQuantity is only supported on quantity items.

Basic Usage​

MaxQuantity​

The maximum value of the quantifiable valueQuantity.value to this question.

MaxQuantity is only supported on quantity items.

Basic Usage​

MaxDecimalPlaces​

The maximum number of decimal places allowed in the numeric answer to this question.

MaxDecimalPlaces is only supported on decimal items.

Basic Usage​

TargetConstraint​

Specifies a constraint that the answer to this question must satisfy, expressed as a FHIRPath expression.

This extension allows you to specify human-readable error messages when the constraint is violated.

Basic Usage​

Multiple Constraints Usage​

Item-Level Constraint Usage​

Constraints can also be defined directly on individual items instead of at the questionnaire root level. When no location is specified, the constraint applies to the item it is defined on.