@@ -159,6 +159,11 @@ pub enum ErrorType {
159
159
pattern : String ,
160
160
} ,
161
161
// ---------------------
162
+ // enum errors
163
+ Enum {
164
+ expected : String ,
165
+ } ,
166
+ // ---------------------
162
167
// dict errors
163
168
DictType ,
164
169
MappingType {
@@ -415,6 +420,7 @@ impl ErrorType {
415
420
Self :: IterationError { .. } => extract_context ! ( IterationError , ctx, error: String ) ,
416
421
Self :: StringTooShort { .. } => extract_context ! ( StringTooShort , ctx, min_length: usize ) ,
417
422
Self :: StringTooLong { .. } => extract_context ! ( StringTooLong , ctx, max_length: usize ) ,
423
+ Self :: Enum { .. } => extract_context ! ( Enum , ctx, expected: String ) ,
418
424
Self :: StringPatternMismatch { .. } => extract_context ! ( StringPatternMismatch , ctx, pattern: String ) ,
419
425
Self :: MappingType { .. } => extract_context ! ( Cow :: Owned , MappingType , ctx, error: String ) ,
420
426
Self :: BytesTooShort { .. } => extract_context ! ( BytesTooShort , ctx, min_length: usize ) ,
@@ -492,6 +498,7 @@ impl ErrorType {
492
498
Self :: StringTooShort { ..} => "String should have at least {min_length} characters" ,
493
499
Self :: StringTooLong { ..} => "String should have at most {max_length} characters" ,
494
500
Self :: StringPatternMismatch { ..} => "String should match pattern '{pattern}'" ,
501
+ Self :: Enum { ..} => "Input should be {expected}" ,
495
502
Self :: DictType => "Input should be a valid dictionary" ,
496
503
Self :: MappingType { ..} => "Input should be a valid mapping, error: {error}" ,
497
504
Self :: ListType => "Input should be a valid list" ,
@@ -628,6 +635,7 @@ impl ErrorType {
628
635
Self :: StringTooShort { min_length } => to_string_render ! ( tmpl, min_length) ,
629
636
Self :: StringTooLong { max_length } => to_string_render ! ( tmpl, max_length) ,
630
637
Self :: StringPatternMismatch { pattern } => render ! ( tmpl, pattern) ,
638
+ Self :: Enum { expected } => to_string_render ! ( tmpl, expected) ,
631
639
Self :: MappingType { error } => render ! ( tmpl, error) ,
632
640
Self :: BytesTooShort { min_length } => to_string_render ! ( tmpl, min_length) ,
633
641
Self :: BytesTooLong { max_length } => to_string_render ! ( tmpl, max_length) ,
@@ -687,6 +695,7 @@ impl ErrorType {
687
695
Self :: StringTooShort { min_length } => py_dict ! ( py, min_length) ,
688
696
Self :: StringTooLong { max_length } => py_dict ! ( py, max_length) ,
689
697
Self :: StringPatternMismatch { pattern } => py_dict ! ( py, pattern) ,
698
+ Self :: Enum { expected } => py_dict ! ( py, expected) ,
690
699
Self :: MappingType { error } => py_dict ! ( py, error) ,
691
700
Self :: BytesTooShort { min_length } => py_dict ! ( py, min_length) ,
692
701
Self :: BytesTooLong { max_length } => py_dict ! ( py, max_length) ,
0 commit comments