Skip to content

Commit 80c1310

Browse files
committed
validation readme
1 parent 6199eb6 commit 80c1310

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Danom.Validation/README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ using FluentValidation;
2727
public record Attendee(
2828
string Name,
2929
int Age,
30-
Option<string> EmailAddress);
30+
Option<string> Email,
31+
Option<string> AlternateEmail);
3132

3233
public class AttendeeValidator
3334
: AbstractValidator<Attendee>
@@ -36,14 +37,16 @@ public class AttendeeValidator
3637
{
3738
RuleFor(x => x.Name).NotEmpty();
3839
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());
4042
}
4143
}
4244
var input =
4345
new Attendee(
4446
Name: "John Doe",
4547
Age: 30,
46-
EmailAddress: Option<string>.None());
48+
Email: Option<string>.Some("[email protected]"),
49+
AlternateEmail: Option<string>.None());
4750

4851
var result =
4952
ValidationResult<Attendee>

0 commit comments

Comments
 (0)