1

When a user has to enter a street address, to ensure clean data is it a good idea to enforce a minimum number of characters?

For instance, I can't see any possible reason a street address could be 2 characters long.

I understand in some countries there is an input for both Street Address 1 and Street Address 2. And I can see how Street Address 2 might be very short (i.e. 2 characters long for an apartment number or something). But if there is only one address field filled out, I think it might be possible a minimum limit is a good idea.

2
  • 4
    is there a reason why you want to restrict the user?
    – Igor-G
    Feb 18, 2013 at 13:39
  • 2
    You'd be making an arbitrary decision, regardless. So I'd avoid arbitrary validation rules.
    – DA01
    Feb 18, 2013 at 15:54

1 Answer 1

9

I would set a minimum length of 1. In some localities you'll get a town consisting of just one street, and a street address consisting of a single digit for the house or building number, plus the town and post code:

1

Tiny Farmville

COUNTY 101010101

To approach this from the other side, a length restriction doesn't particularly help you validate your data.

There are 3 possible types of error I can see would apply here:

  1. User does not enter an address
  2. User deliberately enters an invalid address ("asdf" or "n/a")
  3. User enters an invalid address by mistake ("1 Mpain Street")

Length validation can help you with (1) but not with (2) since the user can just enter a longer invalid address nor with (3) since the invalid address will average the same length as the valid one.

By far the best approach to gathering "clean" address data is to check the input addresses in real time against a "address correction/validation/verification" database or API (these are commercial products that vary wildly from country to country). You can even use these to reduce user input - for example, a common design pattern in the UK is to prompt the user for house number and postcode, do an ajax lookup against a PAF database and present the result from the PAF to user for them to correct or add to.

Of course none of these services are perfect (a good one will provide millions of updates and corrections every year) and so you will also require a backup mechanism for the user to enter a non-matching address.

One last thought - if you're looking for location data that does not represent your users home or work address, then an address verification service is much less useful and you get better data if you allow your user to pinpoint the location on a map (like on FixMyStreet for example)

1
  • 1
    Yep, I think we have some villages with streets "A" and "B". Not kidding! Feb 18, 2013 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.