-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomerCreateCommand.cs
35 lines (28 loc) · 1.18 KB
/
CustomerCreateCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// MIT-License
// Copyright BridgingIT GmbH - All Rights Reserved
// Use of this source code is governed by an MIT-style license that can be
// found in the LICENSE file at https://github.com/bridgingit/bitdevkit/license
namespace BridgingIT.DevKit.Examples.GettingStarted.Application;
using BridgingIT.DevKit.Application.Commands;
using BridgingIT.DevKit.Common;
using BridgingIT.DevKit.Examples.GettingStarted.Domain.Model;
using FluentValidation;
using FluentValidation.Results;
public class CustomerCreateCommand
: CommandRequestBase<Result<Customer>>
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public override ValidationResult Validate() =>
new Validator().Validate(this);
public class Validator : AbstractValidator<CustomerCreateCommand>
{
public Validator()
{
this.RuleFor(c => c.FirstName).NotNull().NotEmpty().WithMessage("Must not be empty.");
this.RuleFor(c => c.LastName).NotNull().NotEmpty().WithMessage("Must not be empty.");
this.RuleFor(c => c.Email).NotNull().NotEmpty().WithMessage("Must not be empty.");
}
}
}