public PreapprovalRequestValidator()
        {
            var addressValidator  = new AddressValidator();
            var customerValidator = new CustomerValidator();

            AddRuleFor(x => x.MethodID)
            .WithPredicate(x => x.MethodID > 0 && Regex.IsMatch(x.MethodID.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.MethodID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <PreapprovalRequest>(x => x.MethodID, ValidationRegexConstants.MethodID));
            AddRuleFor(x => x.MerchantPreapprovalID)
            .WithPredicate(x => !string.IsNullOrWhiteSpace(x.MerchantPreapprovalID) && Regex.IsMatch(x.MerchantPreapprovalID, ValidationRegexConstants.MerchantPreapprovalID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <PreapprovalRequest>(x => x.MerchantPreapprovalID, ValidationRegexConstants.MerchantPreapprovalID));
            AddRuleFor(x => x.RecurringPeriod)
            .WithPredicate(x => x.RecurringPeriod > 0 || Regex.IsMatch(x.RecurringPeriod.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.RecurringPeriod))
            .WithErrorMessage(Operator.InvalidPropertyMessage <PreapprovalRequest>(x => x.RecurringPeriod, ValidationRegexConstants.RecurringPeriod));
            AddRuleFor(x => x.Description)
            .WithPredicate(x => string.IsNullOrWhiteSpace(x.Description) || Regex.IsMatch(x.Description, ValidationRegexConstants.PreapprovalDescription))
            .WithErrorMessage(Operator.InvalidPropertyMessage <PreapprovalRequest>(x => x.Description, ValidationRegexConstants.PreapprovalDescription));
            AddRuleFor(x => x.PreapprovedMaximumAmount)
            .WithPredicate(x => !x.PreapprovedMaximumAmount.HasValue || Regex.IsMatch(x.PreapprovedMaximumAmount.Value.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.Amount))
            .WithErrorMessage(Operator.InvalidPropertyMessage <PreapprovalRequest>(x => x.PreapprovedMaximumAmount, ValidationRegexConstants.Amount));
            AddRuleFor(x => x.Currency)
            .WithPredicate(x => string.IsNullOrWhiteSpace(x.Currency) || Currency.Exists(x.Currency))
            .WithErrorMessage(Operator.InvalidPropertyMessage <PreapprovalRequest>(x => x.Currency));
            AddRuleFor(x => x.ReturnURL)
            .WithPredicate(x => string.IsNullOrWhiteSpace(x.ReturnURL) || Regex.IsMatch(x.ReturnURL, ValidationRegexConstants.PreapprovalReturnURL))
            .WithErrorMessage(Operator.InvalidPropertyMessage <PreapprovalRequest>(x => x.ReturnURL, ValidationRegexConstants.PreapprovalReturnURL));
            AddRuleFor(x => x.MethodOptionID)
            .WithPredicate(x => x.MethodOptionID == 0 || Regex.IsMatch(x.MethodOptionID.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.MethodOptionID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <PreapprovalRequest>(x => x.MethodOptionID, ValidationRegexConstants.MethodOptionID));

            AddInnerValidatorFor(x => x.Customer, () => InnerValidator.Create(customerValidator, true));

            AddInnerValidatorFor(x => x.BillingAddress, () => InnerValidator.Create(addressValidator, true));
        }
예제 #2
0
        public RefundRequestValidator()
        {
            var addressValidator  = new AddressValidator();
            var customerValidator = new CustomerValidator();
            var articleValidator  = new ArticleValidator();

            AddRuleFor(x => x.ID)
            .WithPredicate(x => Regex.IsMatch(x.ID.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.ID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <RefundRequest>(x => x.ID, ValidationRegexConstants.ID));
            AddRuleFor(x => x.MerchantTransactionID)
            .WithPredicate(x => !string.IsNullOrWhiteSpace(x.MerchantTransactionID) && Regex.IsMatch(x.MerchantTransactionID, ValidationRegexConstants.MerchantTransactionID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <RefundRequest>(x => x.MerchantTransactionID, ValidationRegexConstants.MerchantTransactionID));
            AddRuleFor(x => x.OriginatorTransactionID)
            .WithPredicate(x => string.IsNullOrWhiteSpace(x.OriginatorTransactionID) || Regex.IsMatch(x.OriginatorTransactionID, ValidationRegexConstants.OriginatorTransactionID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <RefundRequest>(x => x.OriginatorTransactionID, ValidationRegexConstants.OriginatorTransactionID));
            AddRuleFor(x => x.Amount)
            .WithPredicate(x => x.Amount > 0 && Regex.IsMatch(x.Amount.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.Amount))
            .WithErrorMessage(Operator.InvalidPropertyMessage <RefundRequest>(x => x.Amount));
            AddRuleFor(x => x.Description)
            .WithPredicate(x => string.IsNullOrWhiteSpace(x.Description) || Regex.IsMatch(x.Description, ValidationRegexConstants.Description))
            .WithErrorMessage(Operator.InvalidPropertyMessage <RefundRequest>(x => x.Description, ValidationRegexConstants.Description));

            AddInnerValidatorFor(x => x.Customer, () => InnerValidator.Create(customerValidator, true));

            AddInnerValidatorFor(x => x.BillingAddress, () => InnerValidator.Create(addressValidator, true));

            AddInnerValidatorFor(x => x.BankAddress, () => InnerValidator.Create(addressValidator, true));

            AddInnerValidatorFor(x => x.Articles, () => InnerValidator.Create(new EnumerableValidator <Article>(articleValidator), true));

            AddRuleFor(x => x.TokenLifetime)
            .WithPredicate(x => x.TokenLifetime == null || x.TokenLifetime.Value >= 0)
            .WithErrorMessage(Operator.InvalidPropertyMessage <RefundRequest>(x => x.TokenLifetime));
        }
예제 #3
0
        public CardPayoutRequestValidator()
        {
            var addressValidator  = new AddressValidator();
            var customerValidator = new CustomerValidator();
            var cardValidator     = new CardDetailsRequestValidator();

            AddRuleFor(x => x.MerchantTransactionID)
            .WithPredicate(x => !string.IsNullOrWhiteSpace(x.MerchantTransactionID) && Regex.IsMatch(x.MerchantTransactionID, ValidationRegexConstants.MerchantTransactionID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <CardPayoutRequest>(x => x.MerchantTransactionID, ValidationRegexConstants.MerchantTransactionID));
            AddRuleFor(x => x.Amount)
            .WithPredicate(x => x.Amount > 0 && Regex.IsMatch(x.Amount.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.Amount))
            .WithErrorMessage(Operator.InvalidPropertyMessage <CardPayoutRequest>(x => x.Amount));
            AddRuleFor(x => x.Currency)
            .WithPredicate(x => !string.IsNullOrWhiteSpace(x.Currency) && Currency.Exists(x.Currency))
            .WithErrorMessage(Operator.InvalidPropertyMessage <CardPayoutRequest>(x => x.Currency));
            AddRuleFor(x => x.Description)
            .WithPredicate(x => string.IsNullOrWhiteSpace(x.Description) || Regex.IsMatch(x.Description, ValidationRegexConstants.Description))
            .WithErrorMessage(Operator.InvalidPropertyMessage <CardPayoutRequest>(x => x.Description, ValidationRegexConstants.Description));
            AddRuleFor(x => x.StatementDescriptor)
            .WithPredicate(x => string.IsNullOrWhiteSpace(x.StatementDescriptor) || Regex.IsMatch(x.StatementDescriptor, ValidationRegexConstants.StatementDescriptor))
            .WithErrorMessage(Operator.InvalidPropertyMessage <CardPayoutRequest>(x => x.Description, ValidationRegexConstants.StatementDescriptor));

            AddInnerValidatorFor(x => x.BillingAddress, () => InnerValidator.Create(addressValidator, true));

            AddInnerValidatorFor(x => x.Customer, () => InnerValidator.Create(customerValidator, true));

            AddInnerValidatorFor(x => x.Card, () => InnerValidator.Create(cardValidator, true));
        }
예제 #4
0
        public AlternativePaymentRequestValidator()
        {
            var addressValidator  = new AddressValidator();
            var customerValidator = new CustomerValidator();
            var articleValidator  = new ArticleValidator();

            AddRuleFor(x => x.ID)
            .WithPredicate(x =>
                           Regex.IsMatch(x.ID.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.ID))
            .WithErrorMessage(
                Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.ID, ValidationRegexConstants.ID));
            AddRuleFor(x => x.SkinID)
            .WithPredicate(x =>
                           x.SkinID == null || Regex.IsMatch(x.SkinID.Value.ToString(CultureInfo.InvariantCulture),
                                                             ValidationRegexConstants.SkinID))
            .WithErrorMessage(
                Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.SkinID,
                                                                            ValidationRegexConstants.SkinID));
            AddRuleFor(x => x.MerchantTransactionID)
            .WithPredicate(x =>
                           !string.IsNullOrWhiteSpace(x.MerchantTransactionID) && Regex.IsMatch(x.MerchantTransactionID,
                                                                                                ValidationRegexConstants.MerchantTransactionID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(
                                  x => x.MerchantTransactionID, ValidationRegexConstants.MerchantTransactionID));
            AddRuleFor(x => x.OriginatorTransactionID)
            .WithPredicate(x =>
                           string.IsNullOrWhiteSpace(x.OriginatorTransactionID) || Regex.IsMatch(x.OriginatorTransactionID,
                                                                                                 ValidationRegexConstants.OriginatorTransactionID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(
                                  x => x.OriginatorTransactionID, ValidationRegexConstants.OriginatorTransactionID));
            AddRuleFor(x => x.Amount)
            .WithPredicate(x => x == null || x.Amount.Value > 0 && Regex.IsMatch(x.Amount.Value.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.Amount))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.Amount));
            AddRuleFor(x => x.Currency)
            .WithPredicate(x => !string.IsNullOrWhiteSpace(x.Currency) && Currency.Exists(x.Currency))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.Currency));
            AddRuleFor(x => x.ReturnURL)
            .WithPredicate(x => !string.IsNullOrWhiteSpace(x.ReturnURL) && Regex.IsMatch(x.ReturnURL, ValidationRegexConstants.ReturnURL))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.ReturnURL, ValidationRegexConstants.ReturnURL));
            AddRuleFor(x => x.Description)
            .WithPredicate(x => string.IsNullOrWhiteSpace(x.Description) || Regex.IsMatch(x.Description, ValidationRegexConstants.Description))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.Description, ValidationRegexConstants.Description));
            AddRuleFor(x => x.MethodID)
            .WithPredicate(x => x.MethodID == null || Regex.IsMatch(x.MethodID.Value.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.MethodID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.MethodID, ValidationRegexConstants.MethodID));
            AddRuleFor(x => x.MethodOptionID)
            .WithPredicate(x => x.MethodOptionID == null || Regex.IsMatch(x.MethodOptionID.Value.ToString(CultureInfo.InvariantCulture), ValidationRegexConstants.MethodOptionID))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.MethodOptionID, ValidationRegexConstants.MethodOptionID));
            AddRuleFor(x => x.Guaranteed)
            .WithPredicate(x => x.Guaranteed == null || Regex.IsMatch(x.Guaranteed.ToString(), ValidationRegexConstants.Guaranteed))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.Guaranteed, ValidationRegexConstants.Guaranteed));
            AddRuleFor(x => x.RedirectInIframe)
            .WithPredicate(x => x.RedirectInIframe == null || Regex.IsMatch(x.RedirectInIframe.ToString(), ValidationRegexConstants.Guaranteed))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.RedirectInIframe, ValidationRegexConstants.Guaranteed));
            AddRuleFor(x => x.RedirectMerchantInIframe)
            .WithPredicate(x => x.RedirectMerchantInIframe == null || Regex.IsMatch(x.RedirectMerchantInIframe.ToString(), ValidationRegexConstants.Guaranteed))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.RedirectMerchantInIframe, ValidationRegexConstants.Guaranteed));
            AddRuleFor(x => x.Language)
            .WithPredicate(x => string.IsNullOrWhiteSpace(x.Language) || Regex.IsMatch(x.Language, ValidationRegexConstants.Language))
            .WithErrorMessage(Operator.InvalidPropertyMessage <AlternativePaymentRequest>(x => x.Language, ValidationRegexConstants.Language));

            AddInnerValidatorFor(x => x.BillingAddress, () => InnerValidator.Create(addressValidator, true));

            AddInnerValidatorFor(x => x.ShippingAddress, () => InnerValidator.Create(addressValidator, true));

            AddInnerValidatorFor(x => x.Customer, () => InnerValidator.Create(customerValidator, true));

            AddInnerValidatorFor(x => x.Articles, () => InnerValidator.Create(new EnumerableValidator <Article>(articleValidator), true));
        }