Function: require_choice

Function: require_choice

Usage

 require_choice(choices: some_strings, some_multiple_choice_value)

Requre that at least one of the given choices is selected in a multiple choice value.

If non of the choices is selected, selects the first one.

Parameters

Parameter Type Description
input string Multiple choice value to look update.
choices string Comma separated list of choices of which one is required.

For backwards compatability the following form is also supported:

until 0.3.6
Parameter Type Description
input string Multiple choice value to look update.
choice string Single choice to require.
choice1 string Require multiple choices.
choice2 string etc.

Examples

 require_choice(choices: "red",       "red")          ==  "red"
 require_choice(choices: "red",       "blue")         ==  "blue, red"
 require_choice(choices: "red",       "red, blue")    ==  "red, blue"
 require_choice(choices: "red,green", "red, blue")    ==  "red, blue"
 require_choice(choices: "red,green", "red, green")   ==  "red, blue"
 require_choice(choices: "red,green", "green, blue")  ==  "green, blue"
 require_choice(choices: "red,green", "black, blue")  ==  "black, blue, red"

See also

exclusive_choice Require that at most one of the given choices is selected.
require_exclusive_choice Require that exactly one of the given choices is selected.
remove_choice Remove the given choices from a multiple choice value.