FluentValidation NotEmpty and EmailAddress example

后端 未结 1 1630
庸人自扰
庸人自扰 2021-01-18 00:53

I am using FluentValidation with a login form. The email address field is

Required and Must be a valid email address.

I want to display a

1条回答
  •  鱼传尺愫
    2021-01-18 01:36

    You can just chain them together, it's called Fluent Validation for a reason.

    RuleFor(s => s.Email).NotEmpty().WithMessage("Email address is required")
                         .EmailAddress().WithMessage("A valid email is required");
    

    0 讨论(0)
提交回复
热议问题