Beispiel #1
0
 public static Result <PwdAuthCmd> Create(string password, string email)
 {
     return(ParametersValidation.Validate(
                ParametersValidation.NotNullOrWhiteSpace(password, nameof(password)),
                ParametersValidation.NotNullOrWhiteSpace(email, nameof(email))
                )
            .Combine()
            .Map(() => new PwdAuthCmd(password, email)));
 }
 public static Result <ChangeBalanceCmd> Create(int userId, decimal amount)
 {
     return(ParametersValidation.Validate(
                ParametersValidation.Ensure(() => userId > 0, "Invalid user"),
                ParametersValidation.NotDefaultValue(amount, nameof(amount))
                )
            .Combine()
            .Map(() => new ChangeBalanceCmd(userId, amount)));
 }
Beispiel #3
0
 public static Result <PwdRegistrationCmd> Create(string password, string passwordConfirm, string email)
 {
     return(ParametersValidation.Validate(
                ParametersValidation.NotNullOrWhiteSpace(password, nameof(password)),
                ParametersValidation.Ensure(() => password == passwordConfirm, nameof(passwordConfirm)),
                ParametersValidation.NotNullOrWhiteSpace(email, nameof(email)),
                ParametersValidation.Ensure(() => new EmailAttribute().IsValid(email), nameof(email))
                )
            .Combine()
            .Map(() => new PwdRegistrationCmd(password, email)));
 }