| 2455 | # to opt out of instance_init |
| 2456 | |
| 2457 | def validate(self, obj: t.Any, value: t.Any) -> t.Any: |
| 2458 | with obj.cross_validation_lock: |
| 2459 | for trait_type in self.trait_types: |
| 2460 | try: |
| 2461 | v = trait_type._validate(obj, value) |
| 2462 | # In the case of an element trait, the name is None |
| 2463 | if self.name is not None: |
| 2464 | setattr(obj, "_" + self.name + "_metadata", trait_type.metadata) |
| 2465 | return v |
| 2466 | except TraitError: |
| 2467 | continue |
| 2468 | self.error(obj, value) |
| 2469 | |
| 2470 | def __or__(self, other: t.Any) -> Union: |
| 2471 | if isinstance(other, Union): |