requireMatches

@ApiStatus.Experimental
fun requireMatches(spec: DecisionSpec)

Checks that this response answers the given spec. There must be one answer per question, in the spec's order, and each answer must fit its question the way the typed answer lookup requires: same name and kind, and equal options or levels.

Use it on a response that did not come from this spec's builder, such as one read from JSON or one a provider built itself. As with the typed lookup, a change to a question's instructions is not detected.

For example, when the spec asks urgent and team but the response also answers sentiment, this throws with Extra: 'sentiment'. The names are compared first because the per-answer check pairs each question with the answer at the same position, so an answer with no question would never be checked.

Parameters

spec

the spec this response should answer

Throws

if an answer is missing, extra or out of order, or an answer does not fit its question