We're updating the issue view to help you get more done. 

org.hibernate.validator.constraints.CreditCardNumber does not fail on a non-numbers string

Description

The test invalidTextTest fails.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 import static org.junit.Assert.assertEquals; import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; import org.hibernate.validator.constraints.CreditCardNumber; import org.junit.BeforeClass; import org.junit.Test; public class CreditCardNumberValidatorTest { private static Validator validator; @BeforeClass public static void setUp() { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); validator = factory.getValidator(); } // Ok @Test public void validCardTest() { User user = new User(); user.setCardNumber("4111111111111111"); assertEquals(0, validator.validate(user).size()); } public void invalidNumberTest() { User user = new User(); user.setCardNumber("400"); assertEquals(1, validator.validate(user).size()); } @Test public void invalidTextTest() { User user = new User(); user.setCardNumber("text not numbers"); assertEquals(1, validator.validate(user).size()); } } class User { @CreditCardNumber public String cardNumber; public String getCardNumber() { return cardNumber; } public void setCardNumber(String cardNumber) { this.cardNumber = cardNumber; } }

Environment

None

Status

Assignee

Hardy Ferentschik

Reporter

David Portabella

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

4.3.2.Final

Priority

Minor