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

Public Member Functions

def __init__ (self, *types.Validator validators, typing.Optional[str] error=None)
 
typing.Any __call__ (self, typing.Any value)
 
- Public Member Functions inherited from Validator
str __repr__ (self)
 

Data Fields

 validators
 
 error
 

Static Public Attributes

 default_error_message
 
- Static Public Attributes inherited from Validator
 error
 

Detailed Description

Compose multiple validators and combine their error messages.

Example: ::

    from marshmallow import validate, ValidationError

    def is_even(value):
        if value % 2 != 0:
            raise ValidationError("Not an even value.")

    validator = validate.And(validate.Range(min=0), is_even)
    validator(-1)
    # ValidationError: ['Must be greater than or equal to 0.', 'Not an even value.']

:param validators: Validators to combine.
:param error: Error message to use when a validator returns ``False``.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
*types.Validator  validators,
typing.Optional[str]   error = None 
)

Member Function Documentation

◆ __call__()

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

Reimplemented from Validator.

Field Documentation

◆ default_error_message

default_error_message
static

◆ error

error

◆ validators

validators

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