omarshammas / jquery.formance

A jQuery library for formatting and validating form fields, based on Stripe's jQuery.payment library.
omarshammas.github.io/formancejs
Other
630 stars 105 forks source link

Return instead of throwing errors #15

Open liamgriffiths opened 10 years ago

liamgriffiths commented 10 years ago

I noticed that when inputting a phone number that doesn't match the pattern here will throw a Uncaught TypeError: Cannot read property '0' of null because phoneNumber is null and so we can't access the indicies for the groups.

I think it would be better to just return here rather than throw an error that doesn't really indicate why the function is failing. Is there reason why that was commented out?

https://github.com/omarshammas/jquery.formance/blob/master/src/zfields/phone_number.coffee#L5-L7