Validating postal code


06-Dec-2019 18:35

In any case, all databases are capable of doing adequate syntactic validation when values are inserted or updated.

For example, to prevent empty strings (which are not the same thing as NULL), you can specify a constraint such as: Constraints of this type are declared in the CREATE TABLE statement. There are 256 * 256 = 65536 different ASCII two-character combinations, but only sixty-five of them are official USPS abbreviations.

Imagine the following conversation in your asynchronous group communications tool of choice: OK, what now? With the WLD platform we operate in 7 countries, and none of them agree on a postcode format, so this isn't your standard "google for a quick regular expression" validation.

We had some code for attempting to take any old string and convert it to a formatted postcode (so we can be permissive with the input when looking up latitude and longitude from a postcode) so that was the first stop.

The answer: "It depends." Syntactic correctness is achieved when the values fit the datatype.

For example, the City column would typically be VARCHAR(50) or a similar character datatype, and therefore could contain just about anything.

validating postal code-62

Freewebcamus

Simple and flexible usually go together, so a short while later a module with a handful of methods like ) and the code is up on Git Hub. It is NOT possible to get data in batch or get list of valid postal codes for a given country at a regular interval.