braintree / android-card-form

A ready-made card form layout that can be included in your Android app, making it easy to accept credit and debit cards.
MIT License
366 stars 128 forks source link

Fix validate NullPointerException #63

Closed quinnjn closed 5 years ago

quinnjn commented 5 years ago

Validate checks if the main pattern doesn't match, that a relaxed pattern may match. This relaxed pattern is optional and could be null, resulting in a NPE if the pattern doesn't match.

During testing I realized we don't return false if the pattern is not digits only until the luhn validate, and at that point we throw an exception. The proper thing would have an initial check that the card number is digits only.