Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Machine Learning
avec Scikit-Learn
Voir le programme détaillé
Module « sqlalchemy.orm »

Fonction validates - module sqlalchemy.orm

Signature de la fonction validates

def validates(*names: 'str', include_removes: 'bool' = False, include_backrefs: 'bool' = True) -> 'Callable[[_Fn], _Fn]' 

Description

help(sqlalchemy.orm.validates)

Decorate a method as a 'validator' for one or more named properties.

Designates a method as a validator, a method which receives the
name of the attribute as well as a value to be assigned, or in the
case of a collection, the value to be added to the collection.
The function can then raise validation exceptions to halt the
process from continuing (where Python's built-in ``ValueError``
and ``AssertionError`` exceptions are reasonable choices), or can
modify or replace the value before proceeding. The function should
otherwise return the given value.

Note that a validator for a collection **cannot** issue a load of that
collection within the validation routine - this usage raises
an assertion to avoid recursion overflows.  This is a reentrant
condition which is not supported.

:param \*names: list of attribute names to be validated.
:param include_removes: if True, "remove" events will be
 sent as well - the validation function must accept an additional
 argument "is_remove" which will be a boolean.

:param include_backrefs: defaults to ``True``; if ``False``, the
 validation function will not emit if the originator is an attribute
 event related via a backref.  This can be used for bi-directional
 :func:`.validates` usage where only one validator should emit per
 attribute operation.

 .. versionchanged:: 2.0.16 This paramter inadvertently defaulted to
    ``False`` for releases 2.0.0 through 2.0.15.  Its correct default
    of ``True`` is restored in 2.0.16.

.. seealso::

  :ref:`simple_validators` - usage examples for :func:`.validates`



Vous êtes un professionnel et vous avez besoin d'une formation ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé