Riddler.Screens.Type.BooleanQuestion (Riddler v0.4.0)

Copy Markdown View Source

A question a visitor answers yes or no: a lone checkbox or toggle.

label is what the visitor is asked or agrees to, and it is a template. The response is true or false. required defaults to false, and true means the response must be true - the shape of "tick to agree to the borrowing rules", where an unticked box is the visitor declining rather than an empty field. format is carried and never consulted. A boolean question carries no style: one written on it is a field its type does not name, and admission drops it.

iex> node = %{type: "boolean_question", key: "agrees_to_rules", label: "I agree to the borrowing rules.", required: true}
iex> Riddler.Screens.Type.BooleanQuestion.validate(node)
[]

iex> node = %{type: "boolean_question", key: "agrees_to_rules", label: "I agree to the borrowing rules.", required: "yes"}
iex> [finding] = Riddler.Screens.Type.BooleanQuestion.validate(node)
iex> {finding.code, finding.field}
{"document.invalid_required", "required"}