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))); }
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))); }