Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fenixedu/postcodetools
Utilities for validating post codes
https://github.com/fenixedu/postcodetools
java-library postcode-validation
Last synced: about 2 months ago
JSON representation
Utilities for validating post codes
- Host: GitHub
- URL: https://github.com/fenixedu/postcodetools
- Owner: FenixEdu
- License: mit
- Created: 2018-08-31T09:11:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-22T13:50:09.000Z (over 1 year ago)
- Last Synced: 2024-04-16T11:28:53.841Z (9 months ago)
- Topics: java-library, postcode-validation
- Language: Java
- Size: 80.1 KB
- Stars: 2
- Watchers: 6
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Post Code Tools
## Overview
This library provides a simple Java API for validating a post code for any country.
## Building
```bash
mvn install
```## Using
First, add the dependency to the SDK in your project, module or application.
If you use maven, add the following dependency, adjusting the version adequately:```xml
org.fenixedu
postCodeTools
${version.org.fenixedu.postCodeTools}
```This artifact is available in the following maven repository:
```xml
fenixedu-maven-repository
https://repo.fenixedu.org/fenixedu-maven-repository
```The org.fenixedu.PostalCodeValidator provides a static method for validating post codes.
The method only validates the post code format, not weather the post code actually exists.
The first argument is the ISO 3166 Alfa-2 two letter country code.## Java API
The class org.fenixedu.PostalCodeValidator provides a Java API for validating post code
formats. This class will also provides an example post code and a "human readable" expected
format for each country,```java
public static boolean isValidAreaCode(final String countryCode, final String postCode) { ... }
public static String examplePostCodeFor(final String countryCode) { ... }
public static String formatFor(final String countryCode) { ... }
```## Examples
In the following invocation, the first call will return true, and the second call will return false:
```java
org.fenixedu.PostalCodeValidator.isValidAreaCode("PT", "1049-001");
org.fenixedu.PostalCodeValidator.isValidAreaCode("ES", "1049-001");
```