Git Product home page Git Product logo

lt-codes's Introduction

Lithuanian codes

Personal & company codes validator and generator

Lietuviškų asmens kodo / įmonės kodo tikrinimo bei generavimo funkcijos

Table of Contents

Examples

Examples can be found here:

Instalation

Setup

npm install lt-codes
yarn add lt-codes

Usage

Initialize

import { personalCode, companyCode } from 'lt-codes';

Personal code

Function Description
personalCode.validate(code: string) Validates personal code
personalCode.generate() Generates personal code

Example

const code = '39001010000'; // example
const generatedCode = personalCode.generate();
const { isValid, isException, error } = personalCode.validate(code);

Response (example)

{
  "isValid": true,
  "error": "",
  "isException": true
}

Using Typescript

import { ValidationResult } from 'lt-codes';
const result: ValidationResult = personalCode.validate(code);

Company code

Function Description
companyCode.validate(code: string) Validates company code
companyCode.generate() Generates company code

Example

const code = '123456789'; // example
const generatedCode = companyCode.generate();
const { isValid, isException, error } = companyCode.validate(code);

Response (example)

{
  "isValid": true,
  "error": "",
  "isException": false
}

Using Typescript

import { ValidationResult } from 'lt-codes';
const result: ValidationResult = companyCode.validate(code);

Errors

You can import all error types from lt-codes as use as constants.

import { ValidationError } from 'lt-codes';

error property returned by validate() can be empty or one of the following values:

Value Description
ValidationError.EMPTY Code not passed (empty)
ValidationError.INVALID Do not pass regex checker
ValidationError.INVALID_CONTROL_NUMBER Invalid control number (last digit)
ValidationError.INVALID_DATE Invalid user birth date

lt-codes's People

Contributors

ambrazasp avatar

Stargazers

Arūnas Smaliukas avatar

Watchers

 avatar

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.