1.0.0 • Published 7 years ago

validators-pl v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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 nameParametersDescription
isComplexPasswordString passwordChecks the password complexity. Follows simple regEx rules: one digit, one lowercase, one uppercase letter and one special character from the list: $@!%*?&
isNameString nameChecks if the provided name contains only polish alphabet letters and is a valid polish name
isLocationNumberString numberChecks if the passed number is a valid location number (e.g. apartment, street number)
isPostalCodeString postCodeChecks if provided string is a valid Polish postal code
isCompliantWithPeselString/Date date, String peselChecks if the provided date matches given PESEL (does not check PESEL validity!!! - check the next method)
isValidPeselString peselChecks if the given PESEL is a valid PESEL number
isValidIdNoString idNoChecks if the given string is a valid identification number
isValidPassportNoString passportNoChecks if the provided number is a valid passport number
isValidNipString nipChecks if the provided number is a valid NIP

Testing

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