Commit 80c1310 1 parent 6199eb6 commit 80c1310 Copy full SHA for 80c1310
File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ using FluentValidation;
27
27
public record Attendee (
28
28
string Name ,
29
29
int Age ,
30
- Option <string > EmailAddress );
30
+ Option <string > Email ,
31
+ Option <string > AlternateEmail );
31
32
32
33
public class AttendeeValidator
33
34
: AbstractValidator <Attendee >
@@ -36,14 +37,16 @@ public class AttendeeValidator
36
37
{
37
38
RuleFor (x => x .Name ).NotEmpty ();
38
39
RuleFor (x => x .Age ).GreaterThan (0 );
39
- RuleFor (x => x .EmailAddress ).WhenSome (x => x .EmailAddress ());
40
+ RuleFor (x => x .Email ).Required (x => x .EmailAddress ());
41
+ RuleFor (x => x .AlternateEmail ).Optional (x => x .EmailAddress ());
40
42
}
41
43
}
42
44
var input =
43
45
new Attendee (
44
46
Name : " John Doe" ,
45
47
Age : 30 ,
46
- EmailAddress : Option <string >.None ());
48
+ Email :
Option <
string >.
Some (
" [email protected] " ),
49
+ AlternateEmail : Option <string >.None ());
47
50
48
51
var result =
49
52
ValidationResult < Attendee >
You can’t perform that action at this time.
0 commit comments