validators
Commonly useful validators.
and_(*validators)
A validator that composes multiple validators into one.
When called on a value, it runs all wrapped validators.
:param callables validators: Arbitrary number of validators.
.. versionadded:: 17.1.0
Source code in client/ayon_fusion/vendor/attr/_make.py
2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 |
|
deep_iterable(member_validator, iterable_validator=None)
A validator that performs deep validation of an iterable.
:param member_validator: Validator to apply to iterable members :param iterable_validator: Validator to apply to iterable itself (optional)
.. versionadded:: 19.1.0
:raises TypeError: if any sub-validators fail
Source code in client/ayon_fusion/vendor/attr/validators.py
328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
deep_mapping(key_validator, value_validator, mapping_validator=None)
A validator that performs deep validation of a dictionary.
:param key_validator: Validator to apply to dictionary keys :param value_validator: Validator to apply to dictionary values :param mapping_validator: Validator to apply to top-level mapping attribute (optional)
.. versionadded:: 19.1.0
:raises TypeError: if any sub-validators fail
Source code in client/ayon_fusion/vendor/attr/validators.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
|
in_(options)
A validator that raises a ValueError
if the initializer is called with a value that does not belong in the options provided. The check is performed using value in options
.
:param options: Allowed options. :type options: list, tuple, enum.Enum
, ...
:raises ValueError: With a human readable error message, the attribute (of type attr.Attribute
), the expected options, and the value it got.
.. versionadded:: 17.1.0
Source code in client/ayon_fusion/vendor/attr/validators.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
instance_of(type)
instance_of(type: Type[_T]) -> _ValidatorType[_T]
instance_of(type: Tuple[Type[_T]]) -> _ValidatorType[_T]
instance_of(type: Tuple[Type[_T1], Type[_T2]]) -> _ValidatorType[Union[_T1, _T2]]
instance_of(type: Tuple[Type[_T1], Type[_T2], Type[_T3]]) -> _ValidatorType[Union[_T1, _T2, _T3]]
instance_of(type: Tuple[type, ...]) -> _ValidatorType[Any]
A validator that raises a TypeError
if the initializer is called with a wrong type for this particular attribute (checks are performed using isinstance
therefore it's also valid to pass a tuple of types).
:param type: The type to check for. :type type: type or tuple of types
:raises TypeError: With a human readable error message, the attribute (of type attr.Attribute
), the expected type, and the value it got.
Source code in client/ayon_fusion/vendor/attr/validators.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
is_callable()
A validator that raises a attr.exceptions.NotCallableError
if the initializer is called with a value for this particular attribute that is not callable.
.. versionadded:: 19.1.0
:raises attr.exceptions.NotCallableError
: With a human readable error message containing the attribute (attr.Attribute
) name, and the value it got.
Source code in client/ayon_fusion/vendor/attr/validators.py
281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
matches_re(regex, flags=0, func=None)
A validator that raises ValueError
if the initializer is called with a string that doesn't match regex.
:param str regex: a regex string to match against :param int flags: flags that will be passed to the underlying re function (default 0) :param callable func: which underlying re
function to call (options are re.fullmatch
, re.search
, re.match
, default is None
which means either re.fullmatch
or an emulation of it on Python 2). For performance reasons, they won't be used directly but on a pre-re.compile
\ ed pattern.
.. versionadded:: 19.2.0
Source code in client/ayon_fusion/vendor/attr/validators.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
optional(validator)
A validator that makes an attribute optional. An optional attribute is one which can be set to None
in addition to satisfying the requirements of the sub-validator.
:param validator: A validator (or a list of validators) that is used for non-None
values. :type validator: callable or list
of callables.
.. versionadded:: 15.1.0 .. versionchanged:: 17.1.0 validator can be a list of validators.
Source code in client/ayon_fusion/vendor/attr/validators.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
provides(interface)
A validator that raises a TypeError
if the initializer is called with an object that does not provide the requested interface (checks are performed using interface.providedBy(value)
(see zope.interface <https://zopeinterface.readthedocs.io/en/latest/>
_).
:param interface: The interface to check for. :type interface: zope.interface.Interface
:raises TypeError: With a human readable error message, the attribute (of type attr.Attribute
), the expected interface, and the value it got.
Source code in client/ayon_fusion/vendor/attr/validators.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|