use of com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleLuhn in project connect-sdk-client-android by Ingenico-ePayments.
the class DataRestrictions method getValidationRules.
public List<AbstractValidationRule> getValidationRules() {
validationRules.clear();
if (validators.getExpirationDate() != null) {
AbstractValidationRule validationRule = new ValidationRuleExpirationDate("expirationDate", ValidationType.EXPIRATIONDATE);
validationRules.add(validationRule);
}
if (validators.getFixedList() != null) {
if (validators.getFixedList().getAllowedValues() != null) {
AbstractValidationRule validationRule = new ValidationRuleFixedList(validators.getFixedList().getAllowedValues(), "fixedList", ValidationType.FIXEDLIST);
validationRules.add(validationRule);
}
}
if (validators.getLength() != null) {
if (validators.getLength().getMinLength() != null && validators.getLength().getMaxLength() != null) {
AbstractValidationRule validationRule = new ValidationRuleLength(validators.getLength().getMinLength(), validators.getLength().getMaxLength(), "length", ValidationType.LENGTH);
validationRules.add(validationRule);
}
}
if (validators.getLuhn() != null) {
AbstractValidationRule validationRule = new ValidationRuleLuhn("luhn", ValidationType.LUHN);
validationRules.add(validationRule);
}
if (validators.getRange() != null) {
if (validators.getRange().getMinValue() != null && validators.getRange().getMaxValue() != null) {
AbstractValidationRule validationRule = new ValidationRuleRange(validators.getRange().getMinValue(), validators.getRange().getMaxValue(), "range", ValidationType.RANGE);
validationRules.add(validationRule);
}
}
if (validators.getTermsAndConditions() != null) {
AbstractValidationRule validationRule = new ValidationRuleTermsAndConditions("termsAndConditions", ValidationType.TERMSANDCONDITIONS);
validationRules.add(validationRule);
}
if (validators.getRegularExpression() != null) {
if (validators.getRegularExpression().getRegularExpression() != null) {
AbstractValidationRule validationRule = new ValidationRuleRegex(validators.getRegularExpression().getRegularExpression(), "regularExpression", ValidationType.REGULAREXPRESSION);
validationRules.add(validationRule);
}
}
if (validators.getEmailAddress() != null) {
AbstractValidationRule validationRule = new ValidationRuleEmailAddress("emailAddress", ValidationType.EMAILADDRESS);
validationRules.add(validationRule);
}
if (validators.getBoletoBancarioRequiredness() != null) {
if (validators.getBoletoBancarioRequiredness().getFiscalNumberLength() != null) {
AbstractValidationRule validationRule = new ValidationRuleBoletoBancarioRequiredness(validators.getBoletoBancarioRequiredness().getFiscalNumberLength(), "boletobancariorequiredness", ValidationType.BOLETOBANCARIOREQUIREDNESS);
validationRules.add(validationRule);
}
}
return validationRules;
}
use of com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleLuhn in project connect-sdk-client-android by Ingenico-ePayments.
the class ValidationTest method testValidLuhn.
// Test luhn validator
@Test
public void testValidLuhn() {
PaymentRequest paymentRequest = new TestPaymentRequest();
paymentRequest.setValue("luhn", validLuhnCheck);
ValidationRuleLuhn rule = new ValidationRuleLuhn("", ValidationType.LUHN);
assertEquals(true, rule.validate(paymentRequest, "luhn"));
}
use of com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleLuhn in project connect-sdk-client-android by Ingenico-ePayments.
the class ValidationTest method testInvalidLuhn.
@Test
public void testInvalidLuhn() {
PaymentRequest paymentRequest = new TestPaymentRequest();
paymentRequest.setValue("luhn", invalidLuhnCheck);
ValidationRuleLuhn rule = new ValidationRuleLuhn("", ValidationType.LUHN);
assertEquals(false, rule.validate(paymentRequest, "luhn"));
}
Aggregations