File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
packages/fortifier-macros Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ impl<'a> ValidateEnum<'a> {
5151 let error_variant_idents = self
5252 . variants
5353 . iter ( )
54- . map ( |variant| & variant. ident )
54+ . flat_map ( |variant| variant . error_type ( ) . map ( |_| & variant. ident ) )
5555 . collect :: < Vec < _ > > ( ) ;
5656 let ( error_variant_types, variant_error_types) : ( Vec < _ > , Vec < _ > ) = self
5757 . variants
Original file line number Diff line number Diff line change 1+ use fortifier:: { Validate , ValidationErrors } ;
2+
3+ #[ derive( Validate ) ]
4+ enum FieldType {
5+ Boolean ,
6+ Integer ,
7+ Decimal {
8+ #[ validate( range( max = 10 ) ) ]
9+ scale : u32 ,
10+ } ,
11+ String ( #[ validate( range( min = 1 ) ) ] usize ) ,
12+ }
13+
14+ fn main ( ) -> Result < ( ) , ValidationErrors < FieldTypeValidationError > > {
15+ let data = FieldType :: Boolean ;
16+
17+ data. validate_sync ( ) ?;
18+
19+ let data = FieldType :: Integer ;
20+
21+ data. validate_sync ( ) ?;
22+
23+ let data = FieldType :: Decimal { scale : 3 } ;
24+
25+ data. validate_sync ( ) ?;
26+
27+ let data = FieldType :: String ( 256 ) ;
28+
29+ data. validate_sync ( ) ?;
30+
31+ Ok ( ( ) )
32+ }
You can’t perform that action at this time.
0 commit comments