Пример #1
0
        Either <string, BookTransfer> ValidateBic(BookTransfer transfer)
        {
            if (!_bicRegex.IsMatch(transfer.Bic))
            {
                return("not in bic format");
            }

            return(transfer);
        }
Пример #2
0
        Either <string, BookTransfer> ValidateDate(BookTransfer transfer)
        {
            if (transfer.Date <= DateTime.Now)
            {
                return("Date is in the past");
            }

            return(transfer);
        }
Пример #3
0
        public void Should_bind_function_calls_passing_error()
        {
            var transfer2 = new BookTransfer("11ABaHIJK", DateTime.Now.AddMinutes(1));

            Assert.Equal(F.Left("not in bic format").ToString(), Handle(transfer2).ToString());
        }
Пример #4
0
        public void Should_bind_function_calls_passing_correct_value()
        {
            var transfer1 = new BookTransfer("ABCDEFGHIJK", DateTime.Now.AddMinutes(1));

            Assert.Equal(F.Right(transfer1).ToString(), Handle(transfer1).ToString());
        }
Пример #5
0
 Either <string, BookTransfer> Handle(BookTransfer transfer)
 => F.Right(transfer)
 .Bind(ValidateBic)
 .Bind(ValidateDate);