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

valifino

v0.13.0

Published

Lightweight npm library that provides different financial validators

Downloads

346

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.

Valifino

Install

npm install valifino

Features

API

isValidCreditCardNumber(cardNumber: string): boolean

Validates a credit card number using the Luhn algorithm.

Example:

import { isValidCreditCardNumber} from 'valifino';

/**
 * @param {string} 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 {string} cvv - The CVV code to validate.
 * @param {string} 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 {string} 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 {string} 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)

isValidBBAN(countryCode: string, bban: string): boolean

Validates a Basic Bank Account Number (BBAN) for multiple countries.

import { isValidBBAN } from './valifino';

/**
 * Checks if the provided BBAN (Basic Bank Account Number) is valid for a given country.
 *
 * @param {string} countryCode - The two-letter ISO country code.
 * @param {string} bban - The BBAN to validate.
 * @returns True if the BBAN is valid for the specified country, false otherwise.
 */
isValidBBAN('BE', '539007547034'); // => true (Belgium)
isValidBBAN('BE', 'ABC-0075470-34); // => false

isValidSWIFT(swiftCode: string): boolean

Validates a SWIFT/BIC code.

import { isValidSWIFT } from 'valifino';

/**
 * Validates a SWIFT/BIC code.
 * @param {string} swiftCode - The SWIFT/BIC code to validate.
 * @returns True if the SWIFT/BIC code is valid, false otherwise.
 */
isValidSWIFT('DEUTDEFF'); // => true (Deutsche Bank)
isValidSWIFT('DEUTDEFF!'); // => false (invalid character)

isValidUSRoutingNumber(routingNumber: string): boolean

Validates a US routing number with ABA algorithm.

import { isValidUSRoutingNumber } from 'valifino';

/**
 * Validates a US routing number.
 * @param {string} routingNumber - The US routing number to validate.
 * @returns True if the routing number is valid, false otherwise.
 */
isValidUSRoutingNumber('021000021'); // => true
isValidUSRoutingNumber('021000021!'); // => false (invalid character)

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 {string} 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 2 decimal places are allowed).

import { isValidTransactionAmount } from 'valifino';

/**
 * Validates a transaction amount (up to 2 decimal places are allowed).
 * @param {number} 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

isValidEthereumWalletAddress(walletAddress: string): boolean

Validates an Ethereum crypto wallet address.

import { isValidEthereumWalletAddress } from 'valifino';

/**
 * Validates an Ethereum crypto wallet address.
 * @param {string} walletAddress - The Ethereum wallet address to validate.
 * @returns True if the wallet address is valid, false otherwise.
 */
isValidEthereumWalletAddress('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'); // => true
isValidEthereumWalletAddress('de0B295669a9FD93d5F28D9Ec85E40f4cb697BAe!'); // => false

We Value Your Feedback

At Valifino, we strive to continuously improve and provide the best financial validation library for the community. Your feedback is crucial in helping us achieve this goal!

If you encounter any issues, have suggestions, or would like to request new features, please don't hesitate to open an issue. We welcome and appreciate all contributions, whether it's reporting bugs, sharing ideas, or helping us enhance existing features.

Thank you for supporting Valifino! Together, we can make financial validations easier and more reliable.