asaskevich / govalidator

[Go] Package of validators and sanitizers for strings, numerics, slices and structs
MIT License
6k stars 556 forks source link

Bug in credit card validation #416

Closed asdftamir closed 3 years ago

asdftamir commented 3 years ago

Bug Report

Credit card validation removes non-numeric characters and that causes wrong strings to be accepted.

Summary

the first line in IsCreditCard removes non numeric characters, and then the string "26f71e56d2e54fabae2ca87e5c524fef" passes as a credit card even though it clearly is not.

Current behavior

IsCreditCard("26f71e56d2e54fabae2ca87e5c524fef") returns true

Expected behavior

Remove only spaces and dashes instead of all non-numeric characters