Beispiel #1
0
        public ValidatorResult Validate(RegistrationRequest target)
        {
            if (IsValid(target.Email))
            {
                return(ValidatorResult.Ok());
            }

            return(ValidatorResult.Error("Email", "A valid email address is required"));
        }
Beispiel #2
0
        public ValidatorResult Validate(RegistrationRequest target)
        {
            if (string.IsNullOrWhiteSpace(target.Phone) || !HasValidDigitCount(target.Phone))
            {
                return(ValidatorResult.Error("Phone", "A phone number is required"));
            }

            return(ValidatorResult.Ok());
        }
        public ValidatorResult Validate(RegistrationRequest target)
        {
            decimal amount;

            if (!decimal.TryParse(target.PaymentAmount, out amount))
            {
                amount = 0;
            }

            if (amount < MinPaymentAmount || amount > MaxPaymentAmount)
            {
                return(ValidatorResult.Error("PaymentAmount", $"Payment amount must be between {MinPaymentAmount.ToString("C0")} and {MaxPaymentAmount.ToString("C0")}"));
            }

            return(ValidatorResult.Ok());
        }