Riddler.Screens.Type.BooleanQuestion (Riddler v0.9.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. help is a line of guidance shown beside the question, and it is a template too. 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. default is true or false, presented when nothing else yields a value, and prefill a path under context whose value it presents first. messages maps a code response validation raises on this question - response.required or response.invalid_shape - to the plain string its author shows for it, which a finding with that code carries as author_message. 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"}