You are viewing an older version (5.14.3). Go to latest (5.15.0)
{ } Raw JSON

bundles / traitlets 5.14.3 / traitlets / traitlets / validate

function

traitlets.traitlets:validate

source: /traitlets/traitlets.py :1148

Signature

def   validate ( * names : Sentinel | str )  →  ValidateHandler

Summary

A decorator to register cross validator of HasTraits object's state when a Trait is set.

Extended Summary

The handler passed to the decorator must have one proposal dict argument. The proposal dictionary must hold the following keys:

  • ownerthe HasTraits instance

  • valuethe proposed value for the modified trait attribute

  • traitthe TraitType instance associated with the attribute

Parameters

*names

The str names of the Traits to validate.

Notes

Since the owner has access to the HasTraits instance via the 'owner' key, the registered cross validator could potentially make changes to attributes of the HasTraits instance. However, we recommend not to do so. The reason is that the cross-validation of attributes may run in arbitrary order when exiting the hold_trait_notifications context, and such changes may not commute.

Aliases

  • traitlets.validate