Skip to content
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

Merged
merged 3 commits into from
Sep 28, 2017

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Sep 20, 2017

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.

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.
Copy link
Member

@tvdeyen tvdeyen left a 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?

@mamhoff
Copy link
Contributor Author

mamhoff commented Sep 20, 2017

The presence validation is still there, two lines above the deleted line:
https://github.com/solidusio/solidus/pull/2233/files#diff-14b461f472ff6adbfd491ed5674e4e3aL15

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh. 😆

Copy link
Member

@kennyadsl kennyadsl left a 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 !

Copy link
Contributor

@cbrunsdon cbrunsdon left a 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 👍

@BenMorganIO
Copy link
Contributor

BenMorganIO commented Sep 27, 2017

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.

@mamhoff mamhoff merged commit 9cfc15f into solidusio:master Sep 28, 2017
@mamhoff mamhoff deleted the remove-twitter-cldr branch September 28, 2017 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants