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> {
116116                } , 
117117                input, 
118118            ) ) ; 
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) ? { 
121124            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) ; 
122128        }  else  if  let  Some ( ref  missing)  = self . missing  { 
123-             state. floor_exactness ( Exactness :: Lax ) ; 
124129            let  enum_value = missing. bind ( py) . call1 ( ( input. to_object ( py) , ) ) . map_err ( |_| { 
125130                ValError :: new ( 
126131                    ErrorType :: Enum  { 
@@ -145,10 +150,6 @@ impl<T: EnumValidateValue> Validator for EnumValidator<T> {
145150                ) ) ; 
146151                return  Err ( type_error. into ( ) ) ; 
147152            } 
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) ; 
152153        } 
153154
154155        Err ( ValError :: new ( 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments