At first I thought the com.google.appengine.api.datastore.PostalAddress
class was going to provide some way of validating addresses entered by users in an App Engine app but I don't even know ho开发者_如何学Pythonw to instantiate this class - it doesn't have a public constructor.
Is there a Java library that could be used in an App Engine app to validate postal addresses entered by users?
I don't even know how to instantiate this class - it doesn't have a public constructor.
It does appear to have a public constructor.
Is there a Java library that could be used in an App Engine app to validate postal addresses entered by users?
I think this depends largely on what is considered a valid postal address. It is relatively hard to validate an address that is provided in one single String, since for example to validate the postal code, you first have to know the country to decide if the postal code is valid or not.
According to the docs, that class does have a public constructor. That said, the docs also say this:
A human-readable mailing address. Mailing address formats vary widely so no validation is performed.
I'd look elsewhere for validation if you really need it. What is the purpose of the validation though? Do you need to make sure it's formatted a certain way? Do you need to make sure that it's an actual address? The first would be relatively easy, the second is relatively impossible.
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/PostalAddress.html
... says "Mailing address formats vary widely so no validation is performed."
I also see that the constructor is public but I've never used this before.
To what extent are you attempting to validate? If you're looking for full validation, you may want to look at either UPS or Fedex address verification.
精彩评论