Socket
Book a DemoInstallSign in
Socket

lt-codes

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lt-codes

Lithuanian codes. Personal & company code validator and generator

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
23
-17.86%
Maintainers
1
Weekly downloads
 
Created
Source

Lithuanian codes

Personal & company codes validator and generator

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

Table of Contents

  • Instalation
  • Examples
  • Usage
  • Errors

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

FunctionDescription
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

FunctionDescription
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:

ValueDescription
ValidationError.EMPTYCode not passed (empty)
ValidationError.INVALIDDo not pass regex checker
ValidationError.INVALID_CONTROL_NUMBERInvalid control number (last digit)
ValidationError.INVALID_DATEInvalid user birth date

Keywords

personal

FAQs

Package last updated on 22 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.