-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Postal Code Format Validation (and Twitter CLDR dependency) #2233
Conversation
We shouldn't validate the format of zipcodes. They are vastly different across countries, and the current validation does not tell us anything about whether the address can be shipped to, it only checks the format of the zipcode entered using a regular expresssion. I've briefly thought about adding a customizable address validator class, but that would've prompted users to hook address validation that hits the internet into the ActiveRecord callback chain. We can not want that. The replacement for this must be to validate addresses from host apps. Preferably this takes place at the interaction level rather than at the persistence level, as it is done here. The format validation using Twitter CLDR comes at a cost of a 60MB gem.
In the address factory, we were using Twitter CLDR for generating sample zip codes. We can just as well use FFaker, which conveniently comes with an address faking module for different countries. Our default address is in the USA, so we can use the FFaker::AddressUS module.
We don't need this gem anymore, and it's heavy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m pro this, but why not keep a presence validation?
The presence validation is still there, two lines above the deleted line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh. 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me, thanks @mamhoff !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need a changelog entry but we can hold off until release 👍
I like this. For business owners, address verification is done when generating the shipping label and checking fraud. For me, I can verify the address of orders through EasyPosts address Verification API and Stripes Radar. This covers malicious users. For non-malicious users, or rather, the ones making honest mistakes, we can detect them through services such as Google Maps. I'm 👍 on removing this and perhaps adding fraud checking and verification to the guides for new business owners. They will find much more value out of this. |
The removes the validation of postal code format.
This validation is done through a pretty expensive dependency,
twitter_cldr
, and actually provides little tangible benefit: We don't know whether the postal code enters actually exists if it passes, we only check the format through a regular expression.Stores that rely on this functionality are encouraged to validate the zipcode through something like https://github.com/dgilperez/validates_zipcode, which is a much smaller dependency. We could add that to core, and it would keep the functionality and reduce the size of our bundle, but really I question the benefit of this validation entirely.