Show More
@@ -1059,20 +1059,7 b' class Union(TraitType):' | |||||
1059 | def validate(self, obj, value): |
|
1059 | def validate(self, obj, value): | |
1060 | for trait_type in self.trait_types: |
|
1060 | for trait_type in self.trait_types: | |
1061 | try: |
|
1061 | try: | |
1062 | if value is None and trait_type.allow_none: |
|
1062 | return trait_type._validate(obj, value) | |
1063 | return value |
|
|||
1064 | if hasattr(trait_type, 'validate'): |
|
|||
1065 | return trait_type.validate(obj, value) |
|
|||
1066 | elif hasattr(trait_type, 'is_valid_for'): |
|
|||
1067 | valid = trait_type.is_valid_for(value) |
|
|||
1068 | if valid: |
|
|||
1069 | return value |
|
|||
1070 | else: |
|
|||
1071 | raise TraitError('invalid value for type: %r' % value) |
|
|||
1072 | elif hasattr(trait_type, 'value_for'): |
|
|||
1073 | return trait_type.value_for(value) |
|
|||
1074 | else: |
|
|||
1075 | return value |
|
|||
1076 | except Exception: |
|
1063 | except Exception: | |
1077 | continue |
|
1064 | continue | |
1078 | self.error(obj, value) |
|
1065 | self.error(obj, value) |
General Comments 0
You need to be logged in to leave comments.
Login now