Regex Validation

Hi there,

Anybody knows how to use regex to validate street name field? I want
to avoid things like “st asdkskjfls sdfksf”.
Thanks,

Pedro

I don’t think a regex can save you here. Ask yourself a higher-level
question. Why are you gathering the address information, and why isn’t
it optional? If it’s to send something of value to the person you’re
requesting it from by postal mail, or if you’re using it to help them
find something they need nearby their home, then rest assured they
will enter it with care.

If it’s anything less, you invite this sort of abuse, and you should
either just stop asking the question, or realize that a significant
percentage of entries will be “undeliverable” (to use the Post
Office’s bloodless euphemism).

By the way, I believe the USPS has an address checker API, IIRC, I’ve
used it from PHP before, and there may be a Gem wrapper for it as
well. Ditto FedEx if you’re using them for delivery.

Walter

Walter
Im using address to geocoding. Do you know if exists an address check
plugin or gem to do this work?

Thanks

Pedro

You may be able to find a gem that wraps the USPS database, or FedEx’s (with an
API key from FedEx, and weeks of back-and-forth with their approval team). But it
still gets back to the original “value to the user” question. What exactly do you
give them in return for their successful entry of a real address? Do they think
it’s valuable?

+1 for everything Walter has said about requiring it…

Also… my memory is that yes the USPS has this ability, but it’s not
free (and quite expensive). Google can do it as well. Look into the
geokit-rails stuff. It won’t help with sanitizing the input, but it
will turn it into a lat/long pair if it can.

If location isn’t super super important, just ask for their zip code.
That’s certainly granular enough to do “nearby” type functionality.

Good luck!

-philip

On May 11, 2011, at 10:18 AM, Pedro wrote:

Walter
Im using address to geocoding. Do you know if exists an address check
plugin or gem to do this work?

Thanks

Pedro

I repeat my earlier point. If it’s not valuable enough to the user,
they will spam you like this. If your geocoder reports an error, then
raise it to the user, tell him or her “sorry, having trouble with that
location, could you check the address again?”

You may be able to find a gem that wraps the USPS database, or FedEx’s
(with an API key from FedEx, and weeks of back-and-forth with their
approval team). But it still gets back to the original “value to the
user” question. What exactly do you give them in return for their
successful entry of a real address? Do they think it’s valuable?

Walter

On Wed, May 11, 2011 at 10:26 AM, Fred B. [email protected]
wrote:

 Carefully evaluate whether people really need to enter data.

 If people feel free to enter garbage in a field, should that data

really be asked for?

Aren’t there, potentially, corollaries to this? For instance, Always allow
the people entering data to easily correct or remove their data.

Also, coming from one who has written address validation for credit
reporting, you would not believe the complexity — think of po boxes,
boxes, railroad stops, prefixes/suffixes (w,nw,s,…), apartments,
suites,
rooms… I dont remember exactly why I had to do it but it was one of
those
things I thanked god that I was using tdd :slight_smile:

+1 to everything Walter has said, as well.

I haven’t thought about this a lot, but doesn’t this apply to everything
in
terms of user input? Doesn’t this really enter the realm of a basic
guideline, principle, or law for UI? (I remember something like this
being
applied to database design.)

 Don't make people enter data that they don't care about.

 Don't make people enter data that doesn't affect anything.

 Carefully evaluate whether people really need to enter data.

 If people feel free to enter garbage in a field, should that data

really be asked for?

Aren’t there, potentially, corollaries to this? For instance, Always
allow
the people entering data to easily correct or remove their data.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs