npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pl-registration-plate-validator

v1.0.0

Published

Validate provided Polish registration plate number.

Downloads

103

Readme

pl-registration-plate-validator

Greenkeeper badge Build Status Coverage Status

NPM package for validating user provided Polish registration plate. Works with registration plates issued after 2000 both regular (e.q. WZ 20000) and vanity (WO SIEMA).

In current version package exports a function of {valid, type, voivodeship, county, city} return that takes a string as an argument.

Installation

npm i "pl-registration-plate-validator"

Usage

ES6 / TypeScript

import {validatePlate} from "pl-registration-plate-validator";

const userInput = "WY 52322";
const processedPlate = validatePlate(userInput); // {valid: true, type: regular, voivodeship: mazowieckie, city: Warszawa, county: Wola}
const isPlateValid = processedPlate.valid; // true

ES5

var validePlate = require("pl-registration-plate-validator");
var processedPlate = validatePlate("WQ23003"); // {valid: false}
var isPlateValid = processedPlate.valid; // false

Results

If plate is a valid regular plate returned object is of type

{
    valid: true
    type: "regular"
    voivodeship: string
    county: string
    city: string
}

If it is a valid vanity plate, returned object is of type

{
    valid: true
    type: "vanity"
    voivodeship: string    
}

If it is not a valid plate, in both vanity and regular cases, returned object is of type

{
    valid: false 
}

Changelog

Version 1.0.0

Validation returns object with mandatory "valid" field.

If valid, return will look like

{
    valid: true,
    type: "regular",
    voivodeship: Lubelskie,
    county: Lublin, 
    city: Lublin
}

else

{
    valid: false
}

Version < 1.0.0

Validation returns boolean value.

Under the hood

Package runs a series of tests to determine whether a plate is valid or not. Currently, following conditions are taken into consideration:

  • Start with stripping non letter/digit chars that might be provided alongside prefix, suffix pair (such as input of WU-12345)
  • Return false at the very beginning if first char is not of A-Z (upperCased)
  • Vanity or regular (Second char being a number while third a letter)
  • Length of both types (regular 7-8, vanity 5-7)
  • Prefix existence in provided JSON data files(both XY and XYZ prefixes)
  • Vanity plate suffix can contain of no more than 2 digits, placed in two last chars.

Dev

  1. git pull https://github.com/szwarckonrad/pl-registration-plate-validator.git
  2. npm i -D
  3. Scripts:
    • npm run build Builds with TSC to ES5 .js module
    • npm run test Fire ups Jest tests

TODO

  1. Add description of tests module runs to determine whether the plate is valid or not.
  2. ~~Add verbose mode that will return an object with detailed info on the plate.~~ v1.0.0