Validator
Simple Promise based API to validate different tasks.
Table of contents
How to Setup:
Just include the following in your project:
const validate = ;
If your process supports it, you can use ES6 imports like the following:
;
And then just remove the validate.
from the examples below.
How to Use:
Address Validator
For US based addresses via USPS API.
First you need to register for an API key / User ID here.
Once you have your User ID, you can begin using the validator like so:
validate
The result of the above should return this:
street: "350 5TH AVE" city: "NEW YORK" state: "NY" zip: "10118"
You can catch any errors, like the following:
validate;
You'll get back an error like this:
error: "Invalid Zip Code."
City/State Lookup
For looking up what the City / State is for a supplied Zip Code.
Similar setup process to the Address Validator, except instead of passing a whole address, you just pass the Zip Code.
If you run the following:
validate
You should get back a response like this:
city: "NEW YORK" state: "NY" zip: "10118"
You can catch any errors, like the following:
validate;
You'll get back an error like this:
error: "Invalid Zip Code."