@Test(groups = "fast") public void validNumber() { CreditCardTypeConverter c = new CreditCardTypeConverter(); Assert.assertEquals(c.convert("4111111111111111", String.class, new ArrayList<ValidationError>()), "4111111111111111"); }
public String convert(String input, Class<? extends String> targetType, Collection<ValidationError> errors) { String cardNumber = input.replaceAll("\\D", ""); if (getCardType(cardNumber) != null) { return cardNumber; } errors.add(new ScopedLocalizableError("converter.creditCard", "invalidCreditCard")); return null; }
CreditCardTypeConverter implements TypeConverter<String> { public String convert(String input, Class<? extends String> targetType, Collection<ValidationError> errors) { String cardNumber = input.replaceAll("\\D", ""); if (getCardType(cardNumber) != null) { return cardNumber; } errors.add(new ScopedLocalizableError("converter.creditCard", "invalidCreditCard")); return null; } }
CreditCardTypeConverter implements TypeConverter<String> { public String convert(String input, Class<? extends String> targetType, Collection<ValidationError> errors) { String cardNumber = input.replaceAll("\\D", ""); if (getCardType(cardNumber) != null) { return cardNumber; } errors.add(new ScopedLocalizableError("converter.creditCard", "invalidCreditCard")); return null; }  }
CreditCardTypeConverter implements TypeConverter<String> { public String convert(String input, Class<? extends String> targetType, Collection<ValidationError> errors) { String cardNumber = input.replaceAll("\\D", ""); if (getCardType(cardNumber) != null) { return cardNumber; } errors.add(new ScopedLocalizableError("converter.creditCard", "invalidCreditCard")); return null; }  void setLocale(Locale locale); String convert(String input, Class<? extends String> targetType, Collection<ValidationError> errors); static Type getCardType(String cardNumber); }
CreditCardTypeConverter implements TypeConverter<String> { public String convert(String input, Class<? extends String> targetType, Collection<ValidationError> errors) { String cardNumber = input.replaceAll("\\D", ""); if (getCardType(cardNumber) != null) { return cardNumber; } errors.add(new ScopedLocalizableError("converter.creditCard", "invalidCreditCard")); return null; }  void setLocale(Locale locale); String convert(String input, Class<? extends String> targetType, Collection<ValidationError> errors); static Type getCardType(String cardNumber);  }