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

@deposits/validators

v0.0.8

Published

A collection of Fintech-specific and general-purpose validators, designed to extend popular validation libraries like Vuelidate, Zod, and yup.

Downloads

302

Readme

Deposits Validators

Overview

This repository contains a list of validators that are relevant to the Fintech space. It provides a bunch of sector-specific validators as well as other validators that don't normally come out of the box in libraries like Vuelidate, Zod and yup.

All validators in this library are pure functions that return Boolean values so they can be used to extend your favorite validation library out of the box.

Installation

To install the validators, simply run the following command in your project directory:

npm install @deposits/validators

Basic Usage

Since the package exports pure functions that return Booelan values, you just need to import the validator you need and use it as is or plug it into a validation library.

import { email } from "@deposits/validators";

Usage with Vuelidate

<template>
  <script setup>
    import { email } from "@deposits/validators";
    import { helpers, required } from "@vuelidate/validators";
    import { useVuelidate } from "@vuelidate/core";
    import { reactive } from "vue";

    const payload = reactive({
      email: "",
      password: "",
    });

    const rules = {
      email: {
        required: helpers.withMessage("Email is required", required),
        email: helpers.withMessage("Please enter a valid email", email),
      },
      password: {
        required: helpers.withMessage("Password is required", required),
      },
    };

    const v$ = useVuelidate(rules, payload, { $stopPropagation: true });

    const submit = () => {
      v$.value.$validate();
      if (!v$.value.$error) {
        // Submit
      }
    };
  </script>
</template>

Usage with yup

import { routingNumber, accountNumber } from "@deposits/validators";
import { object, string } from "yup";

const schema = object().shape({
  accountNumber: string()
    .required("Please enter account number")
    .test("account-number", "Enter a valid account number", accountNumber),
  routingNumber: string()
    .required("Please enter a routing number")
    .test("routingNumber", "Enter a valid routing number", routingNumber),
});

Available Validation Rules

The following validators are available in this package:

accountNumber

This checks if the value being validated is a valid US account number. It should be a numeric string consisting of between 4-17 digits.

creditCard

This checks if the value being validated is a valid credit card number. It should be a numeric string consisting of between 13-19 digits and should pass the Luhn's checksum algorithm as well as prefix and suffix checks for different card providers.

ein

This checks if the value being validated is a valid EIN. It expects a numeric string in the format XX-XXXXXXX.

email

This checks if the value being validated is a valid email address.

itin

This checks if the value being validated is a valid Individual Taxpayer Identification Number (ITIN). It expects a numeric string in the format 9XX-XX-XXXX.

naics

This checks if the value being validated is a valid North American Industry Classification System (NAICS) code.

name

This checks if the value being validated is a valid name. It expects a string with a length between 2 and 40 characters.

oneWord

This checks that the value being validated is a single word. It expects a string with at least one character and no spaces.

passportNumber

This validates if the value being validate is a valid passport number. It expects a string with a length between 6 and 9 characters.

routingNumber

This checks if the value being validated is a valid US routing number. It should be a numeric string consisting of 9 digits and passes the ABA checksum algorithm.

ssn

This checks if the value being validated is a valid Social Security Number (SSN). It expects a numeric string in the format XXX-XX-XXXX.

strongPassword

This checks if the value being validated is a "strong" password. It expects a string that is at least 8 characters in length and contains at least one of a lower case letter, upper case letter, number and special character.

swiftCode

This checks if the value being validated is a valid SWIFT code. It should be an alphanumeric string consisting of 8 or 11 characters.

suffix

This checks if the value being validated is a valid suffix. It expects a string with a length between 2 and 10 characters.

zip

This checks if the value being validated is a zip code. It should be a numeric string with a length of 5 characters.