JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q63199F
  • License MIT

Lightweight npm library that provides different financial validators

Package Exports

  • valifino
  • valifino/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (valifino) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Valifino

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

A comprehensive library of financial validators for Node.js, built using TypeScript. This library provides a set of functions to validate various financial instruments and formats such as credit card numbers, IBANs, SWIFT/BIC codes, and more.

Install

npm install valifino

Features

  • Validate credit card numbers using the Luhn algorithm
  • Validate CVV codes for various card types
  • Validate expiration dates of credit cards
  • Validate IBANs for multiple countries
  • Validate SWIFT/BIC codes [To be done]
  • Validate routing numbers (e.g., ABA routing numbers) [To be done]
  • Validate bank account numbers [To be done]
  • Validate currency codes
  • Validate transaction amounts
  • Validate cryptocurrency addresses (e.g., Bitcoin, Ethereum) [To be done]

API

isValidCreditCardNumber(cardNumber: string): boolean

Validates a credit card number using the Luhn algorithm.

Example:

import { isValidCreditCardNumber} from 'valifino';

/**
 * @param cardNumber - The card number in string format.
 * @returns True if the card number is valid, false otherwise.
 */
isValidCreditCardNumber('4111111111111111'); // => true

isValidCVV(cardType: string, cvv: string): boolean

Validates the CVV code of a credit card based on the card type.

Example:

import { isValidCVV } from 'valifino';

/**
 * Validates the CVV code for the given card type.
 * @param cvv - The CVV code to validate.
 * @param cardType - The type of the card (e.g., CardType.Visa, CardType.MasterCard).
 * @returns True if the CVV is valid, false otherwise.
 */
isValidCVV(123, 'Visa'); // => true
isValidCVV(432, 'Amex'); // => false

isValidExpirationDate(expirationDate: string): boolean

Validates the expiration date of a credit card.

import { isValidExpirationDate } from 'valifino';

/**
 * @param expirationDate - The expiration date in the format MM/YY or MM/YYYY.
 * @returns True if the expiration date is valid, false otherwise.
 */
isValidExpirationDate('12/2029'); // => true
isValidExpirationDate('01-2025'); // => false

isValidIBAN(iban: string): boolean

Validates an International Bank Account Number (IBAN) for multiple countries.

import { isValidIBAN } from 'valifino';

/**
 * Checks whether a given string is a valid International Bank Account Number (IBAN).
 * @param iban The IBAN to validate.
 * @returns `true` if the IBAN is valid, `false` otherwise.
 */
isValidIBAN('MD75EX0900002374642125EU'); // => true (Moldova IBAN)
isValidIBAN('BE68539007547035'); // => false (incorrect digit check)

isValidSWIFTBIC [TBD]

isValidRoutingNumber [TBD]

isValidAccountNumber [TBD]

isValidCurrencyCode(currencyCode: string): boolean

Validates a currency code based on the ISO 4217 standard.

import { isValidCurrencyCode } from 'valifino';

/**
 * Validates a currency code against the ISO 4217 standard.
 * @param currencyCode - The currency code to validate.
 * @returns True if the currency code is valid, false otherwise.
 */
isValidCurrencyCode('USD'); // => true
isValidCurrencyCode('XYZ'); // => false

isValidTransactionAmount(amount: number): boolean

Validates a transaction amount (up to 3 decimal places are allowed).

import { isValidTransactionAmount } from 'valifino';

/**
 * Validates a transaction amount (up to 3 decimal places are allowed).
 * @param amount - The transaction amount to validate.
 * @returns True if the transaction amount is valid, false otherwise.
 */
isValidTransactionAmount(100.0); // => true
isValidTransactionAmount(100.1234); // => false
isValidTransactionAmount(-50.00); // => false

isValidCryptoAddress [TBD]