Skip to content

A few validators for polish IDs and password constraints

License

Notifications You must be signed in to change notification settings

SzybkiSasza/validators-pl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Codacy Badge Codacy Badge

Polish validators

Simple set of validators to validate polish data. Useful in any type of online forms.

Browser and NodeJS support

Library currently supports all the browsers that have > 5% of market share and current LTS versions of NodeJS.

The library code is minified. For the original code, please refer to the GitHub repo.

Library methods are exposed both as classic module.exports and ES6 exports.

Adding to a project

To use library, install it with npm or yarn:

  • npm i --save validators-pl
  • yarn add validators-pl

Standard module imports

For the standard environment, use require or amd:

const validators = require('validators-pl');
const isValidPesel = validators.isValidPesel(89101012345);

ES6 imports

Using ES6 imports, you can include only the part of library that you need (which is useful for tree shaking and minifying, supported by tools like Webpack):

import {isValidPesel} from 'validators-pl';
const isValidPesel = isValidPesel(89101012345);

Available validators

Provided validators are related only to polish ID data.

Method name Parameters Description
isComplexPassword String password Checks the password complexity. Follows simple regEx rules: one digit, one lowercase, one uppercase letter and one special character from the list: $@!%*?&
isName String name Checks if the provided name contains only polish alphabet letters and is a valid polish name
isLocationNumber String number Checks if the passed number is a valid location number (e.g. apartment, street number)
isPostalCode String postCode Checks if provided string is a valid Polish postal code
isCompliantWithPesel String/Date date, String pesel Checks if the provided date matches given PESEL (does not check PESEL validity!!! - check the next method)
isValidPesel String pesel Checks if the given PESEL is a valid PESEL number
isValidIdNo String idNo Checks if the given string is a valid identification number
isValidPassportNo String passportNo Checks if the provided number is a valid passport number
isValidNip String nip Checks if the provided number is a valid NIP

Testing

Tests can be run by running npm test from the library directory.