Giter Club home page Giter Club logo

nino-format-validation's Introduction

NinoValidator

Build Status Known Vulnerabilities

This class performs validation of a National Insurance Number (Nino) format. It uses regex to do this. There is no validation that the nino itself is valid. There is no data lookup functionality.

The class includes the ability to discover the day of week on which various social security benefits are payable.

The class has two static methods to validate user input, or it can be used dynamically to query the nino itself.

The static methods fall into 'loose' and 'strict' validation criteria, where a 'strictly valid' nino must follow the criteria set within Corporate Data Standards reference CV0013 which are as follows:

  • The NI Number must be 9 characters long with no spaces
  • The first two characters must be alphabetical
  • Characters three to eight must be numeric
  • Character nine must be A, B, C, D, or a space **
  • The first character must not be D, F, I, Q, U, or V
  • The second character must not be D, F, I, O, Q, U, or V
  • The first two characters must not be combinations of GB, NK, TN, or ZZ (this includes the reverse of each combination, so BG, KN, and NT are also not valid)

** from 1.3.0 onwards the suffix must be supplied (ie. cannot be blank) and must contain a letter (ie. spaces are not allowed).

A 'loosely valid' nino, on the other hand, can be between 9 and 13 characters long, where the nino can contain spaces and the last character can be optionally blank (i.e., AA 37 07 73 A and AA370773A are all loosely valid, but only AA370773Ais strictly valid).

For example the following will return true because AA 37 07 73 A is a 'loosely valid' nino.

NinoValidator.validateNINO("AA 37 07 73 A");

But the following will return false because AA 37 07 73 A is not a 'strictly valid' nino.

NinoValidator.validateStrictNINO("AA 37 07 73 A")

Project inclusion

properties entry in pom

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

dependency reference

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

Example of use

import uk.gov.dwp.regex.NinoValidator;

declaration

NinoValidator ninoValidator = new NinoValidator("AA370773A");

or

NinoValidator ninoValidator = new NinoValidator("AA370773", "A");

Use

NinoValidator.validateNINO("AA370773A")

NinoValidator.validateStrictINO("AA370773A")

NinoValidator.returnDayOfWeek("AA370773A");

or

NinoValidator ninoValidator = new NinoValidator("AA370773A");

ninoValidator.validateThis()

ninoValidator.validateThisStrict()

ninoValidator.returnThisDayOfWeek();

An InvalidNinoException will be thrown if an error occurs.

nino-format-validation's People

Contributors

healthpdu avatar timja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nino-format-validation's Issues

Update vulnerable version of junit 4.12 > 4.13.1

Snyk is warning me that nino-validation introduces a vulnerable version of junit (4.12):

Introduced through: Snyk_IA_API@local › uk.gov.dwp.regex:[email protected] › junit:[email protected]

More details on the issue are here:
https://security.snyk.io/vuln/SNYK-JAVA-JUNIT-1017047

There is already an open pull request from snyk-bot with the update to junit4.13.1 that should resolve this:
#3

Can you merge this and release a new version of nino-validation please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.