Validator which succeeds if ``value`` is a member of ``choices``.
:param choices: A sequence of valid values.
:param labels: Optional sequence of labels to pair with the choices.
:param error: Error message to raise in case of a validation error. Can be
interpolated with `{input}`, `{choices}` and `{labels}`.
typing.Iterable[typing.Tuple[typing.Any, str]] options |
( |
|
self, |
|
|
typing.Union[str, typing.Callable[[typing.Any], typing.Any]] |
valuegetter = str |
|
) |
| |
Return a generator over the (value, label) pairs, where value
is a string associated with each choice. This convenience method
is useful to populate, for instance, a form select field.
:param valuegetter: Can be a callable or a string. In the former case, it must
be a one-argument callable which returns the value of a
choice. In the latter case, the string specifies the name
of an attribute of the choice objects. Defaults to `str()`
or `str()`.