File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -116,11 +116,16 @@ impl<T: EnumValidateValue> Validator for EnumValidator<T> {
116
116
} ,
117
117
input,
118
118
) ) ;
119
- } else if let Some ( v) = T :: validate_value ( py, input, & self . lookup , strict) ? {
120
- state. floor_exactness ( Exactness :: Lax ) ;
119
+ }
120
+
121
+ state. floor_exactness ( Exactness :: Lax ) ;
122
+
123
+ if let Some ( v) = T :: validate_value ( py, input, & self . lookup , strict) ? {
121
124
return Ok ( v) ;
125
+ } else if let Ok ( res) = class. as_unbound ( ) . call1 ( py, ( input. as_python ( ) , ) ) {
126
+ // as a last result, just try to initialize the enum with the input
127
+ return Ok ( res) ;
122
128
} else if let Some ( ref missing) = self . missing {
123
- state. floor_exactness ( Exactness :: Lax ) ;
124
129
let enum_value = missing. bind ( py) . call1 ( ( input. to_object ( py) , ) ) . map_err ( |_| {
125
130
ValError :: new (
126
131
ErrorType :: Enum {
@@ -145,10 +150,6 @@ impl<T: EnumValidateValue> Validator for EnumValidator<T> {
145
150
) ) ;
146
151
return Err ( type_error. into ( ) ) ;
147
152
}
148
- } else if let Ok ( res) = class. as_unbound ( ) . call1 ( py, ( input. as_python ( ) , ) ) {
149
- // as a last result, just try to initialize the enum with the input
150
- state. floor_exactness ( Exactness :: Lax ) ;
151
- return Ok ( res) ;
152
153
}
153
154
154
155
Err ( ValError :: new (
You can’t perform that action at this time.
0 commit comments