uk.gov.dwp.regex:postcode-validation

Encapsulated utility to validate and extract various markers from a UK postcode

License

License

GroupId

GroupId

uk.gov.dwp.regex
ArtifactId

ArtifactId

postcode-validation
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

uk.gov.dwp.regex:postcode-validation
Encapsulated utility to validate and extract various markers from a UK postcode
Project URL

Project URL

https://github.com/dwp/postcode-format-validation
Source Code Management

Source Code Management

https://github.com/dwp/postcode-format-validation

Download postcode-validation

How to add to project

<!-- https://jarcasting.com/artifacts/uk.gov.dwp.regex/postcode-validation/ -->
<dependency>
    <groupId>uk.gov.dwp.regex</groupId>
    <artifactId>postcode-validation</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/uk.gov.dwp.regex/postcode-validation/
implementation 'uk.gov.dwp.regex:postcode-validation:1.1.0'
// https://jarcasting.com/artifacts/uk.gov.dwp.regex/postcode-validation/
implementation ("uk.gov.dwp.regex:postcode-validation:1.1.0")
'uk.gov.dwp.regex:postcode-validation:jar:1.1.0'
<dependency org="uk.gov.dwp.regex" name="postcode-validation" rev="1.1.0">
  <artifact name="postcode-validation" type="jar" />
</dependency>
@Grapes(
@Grab(group='uk.gov.dwp.regex', module='postcode-validation', version='1.1.0')
)
libraryDependencies += "uk.gov.dwp.regex" % "postcode-validation" % "1.1.0"
[uk.gov.dwp.regex/postcode-validation "1.1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

PostCodeValidator

Build Status Known Vulnerabilities

This class performs validation of a postcode format. It uses regex to do this. There is no validation that the postcode itself is valid. There is no data lookup functionality.

The class includes the BFPO format and has a query for a NI postcode.

The class has a static method to validate user input, or it can be used dynamically to query the postcode itself.

For example: PostCodeValidator.validateInput("AA9B 9DD"); will return true as AA9B9DD is in a valid format.

PostCodeValidator postcodeValidator = new PostCodeValidator("AA9B 9DD"); Both validates the input and configures the variable. If the input is not in valid postcode format, an InvalidPostcodeException will be thrown.

Project inclusion

properties entry in pom

<properties>
    <dwp.formatvalidation.postcode>x.x</dwp.formatvalidation.postcode>
</properties>

dependency reference

<dependency>
    <groupId>uk.gov.dwp.regex</groupId>
    <artifactId>postcode-validation</artifactId>
    <version>${dwp.formatvalidation.postcode}</version>
</dependency>

Example of use

import uk.gov.dwp.regex.PostCodeValidator;

declaration

PostCodeValidator postcodeValidator = new PostCodeValidator("AA9B 9DD");

Use example

postcodeValidator.returnArea()

or statically as:

PostCodeValidator.validateInput("AA9B 9DD");

uk.gov.dwp.regex

Department for Work and Pensions

Public repository for tools and technologies developed within the DWP.

Versions

Version
1.1.0