OpenQuizz
Une application de gestion des contenus pédagogiques
OneOf Class Reference
Inheritance diagram for OneOf:
Collaboration diagram for OneOf:

Public Member Functions

def __init__ (self, typing.Iterable choices, typing.Optional[typing.Iterable[str]] labels=None, *typing.Optional[str] error=None)
 
typing.Any __call__ (self, typing.Any value)
 
typing.Iterable[typing.Tuple[typing.Any, str]] options (self, typing.Union[str, typing.Callable[[typing.Any], typing.Any]] valuegetter=str)
 
- Public Member Functions inherited from Validator
str __repr__ (self)
 

Data Fields

 choices
 
 choices_text
 
 labels
 
 labels_text
 
 error
 

Static Public Attributes

 default_message
 
- Static Public Attributes inherited from Validator
 error
 

Detailed Description

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}`.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
typing.Iterable  choices,
typing.Optional[typing.Iterable[str]]   labels = None,
*typing.Optional[str]   error = None 
)

Member Function Documentation

◆ __call__()

typing.Any __call__ (   self,
typing.Any  value 
)

Reimplemented from Validator.

◆ options()

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()`.

Field Documentation

◆ choices

choices

◆ choices_text

choices_text

◆ default_message

default_message
static

◆ error

error

◆ labels

labels

◆ labels_text

labels_text

The documentation for this class was generated from the following file: