constraintText method
The constraint message (in textForm, if given), evaluated with
attemptedValue as the candidate; null without a constraint.
Implementation
String? constraintText({String? textForm, AnswerValue? attemptedValue}) {
final constraint = treeElement.constraint;
if (constraint is! Constraint) return null;
final ec = EvaluationContext.withContext(
form.evaluationContext,
treeElement.ref,
);
if (textForm != null) ec.outputTextForm = textForm;
if (attemptedValue != null) {
ec
..isConstraint = true
..candidateValue = attemptedValue;
}
return substituteStringArgs(
constraint.constraintMessage(ec, form.mainInstance, textForm),
);
}