Properties

Constraints

Properties that bound or validate respondent input — required, min/max/exact, sum, decimal, validation. The rules the runtime checks before letting a respondent move on.

required

Whether the respondent must answer before proceeding.

- qid: QBrand
    type: single
    text: Which brand?
    required: True       # default for answer-bearing types

required: False lets the respondent skip. Typical use: optional follow-ups, hidden helper questions.

required has no effect on info (which collects no answer) and defaults to False for readonly: True questions (the respondent can’t interact with them anyway).

min / max — answer count

For multi-answer types, min and max constrain how many items the respondent must / can pick.

- qid: QFeatures
    type: multi
    text: Which features matter? Pick 2–4.
    min: 2
    max: 4
    options:
        1: Battery
        2: Camera
        3: Screen
        4: Build
        5: Price

For numberList, gridNumber, and number, min / max constrain the value instead.

- qid: QAge
    type: number
    min: 13
    max: 120

For openList, min / max constrain how many rows must have text.

exact — exact answer count

exact: N forces exactly N selections. Overrides min and max if both are set.

- qid: QTop3
    type: rank
    text: Rank your top three.
    exact: 3
    options:
        1: Apple
        2: Samsung
        3: Sony
        4: LG

sum / total — aggregate constraints

For numberList and gridNumber, the values across rows or cells can be constrained to sum to a target.

- qid: QAllocate
    type: numberList
    text: Allocate 100 points across these.
    sum: 100
    options:
        1: Service
        2: Price
        3: Reliability
        4: Brand

total: True shows a running total to the respondent (useful when sum is set so they can see if they’re at the target). On gridNumber, direction: rows totals per row; direction: cols totals per column.

decimal

Allow fractional values on number, numberList, gridNumber. Default False.

- qid: QTemp
    type: number
    text: Body temperature in Celsius.
    min: 35
    max: 42
    decimal: True
    decimal.places: 1

decimal.places limits precision. Without it, the runtime accepts any number of decimals.

validation — Python-checked rule

For anything beyond min/max/exact, write a validation: block. Python that runs after the respondent answers; calls fail("msg") to reject.

- qid: QEmail
    type: open
    text: Email address
    validation: |
        if "@" not in QEmail.value:
            fail("Please enter a valid email.")
- qid: QSpend
    type: numberList
    text: Spending by category
    options:
        1: Food
        2: Travel
        3: Entertainment
    validation: |
        # Travel must be no more than half of total
        total = sum(QSpend.row(c).value for c in [1, 2, 3])
        if total > 0 and QSpend.row(2).value / total > 0.5:
            fail("Travel cannot exceed half of total spend.")

fail accepts a language code and a message. The full Python subset available is documented under Builtins & operators.

input.maxChar / input.minChar — text length

Limit the length of text entered into open / openList / specify fields.

- qid: QFeedback
    type: open
    text: Anything else?
    input.maxChar: 500
    input.minChar: 10

readonly — exempt from interaction

readonly: True hides the question from the respondent while still storing and exporting its computed value. Standard pattern for hidden helper questions.

- qid: hRegion
    type: single
    options: regionList
    readonly: True
    required: False

How constraints compose

Set togetherBehaviour
min and maxBoth apply. Respondent must select within the range.
min / max and exactexact wins. The other two are ignored.
required: True and readonly: TrueValidator rejects — contradictory.
sum and min/max per rowAll apply. Each row meets its own bounds; the aggregate meets sum.

See also