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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cruk/fundraising-data-validations

v4.3.2

Published

Validation rules for fundraising data

Readme

Fundraising data validations

This internal CRUKorg package provides regular expressions to validate commonly collected supporter data in fundraising products, ensuring the data meets the minimum requirements for downstream systems.

The motivation for creating this package is to standardise these validation rules to avoid duplicated interpretation of them in multiple products and minimise risks of passing invalid data downstream. This package is designed to be used in frontend forms and on backend services accepting any payloads of data to be sent downstream.

Usage

To install the package locally

  1. Run npm install @crukorg/fundraising-data-validations in your terminal.
  2. Import the relevant schema into your validation files, e.g.
import { supporterSchema } from "@crukorg/fundraising-data-validations";

const isValidFirstName =
  supporterSchema.firstName.allowedCharacters.regex.test(inputFirstName);

if (!isValidFirstName) {
  return supporterSchema.firstName.allowedCharacters.errorMessage;
}

Zod example:

import { z } from "zod";
import { supporterSchema } from "@cruk/fundraising-data-validations";

const isValidSupporter = z
  .object({
    firstName: z
      .string()
      .trim()
      .regex(
        supporterSchema.firstName.minMaxLength?.regex,
        supporterSchema.firstName.minMaxLength?.errorMessage,
      )
      .regex(
        supporterSchema.firstName.allowedCharacters.regex,
        supporterSchema.firstName.allowedCharacters.errorMessage,
      ),
  })
  .required({
    firstName: supporterSchema.firstName.isRequired?.required,
  });

try {
  isValidSupporter.parse(inputSupporter);
} catch (error) {
  if (error instanceof ZodError) {
    const errorMessages = prettifyError(error);
    console.error(errorMessages);
  }
}
  1. You may add additional, stricter rules on top of these validations, but these rules should form the foundation of any validations for form data.

Required and optional validation

Each field has several rules available for use. In each case, required and allowedCharacters regexes are the minimum required rules. Most of the fields also have a minMaxLength rule, the only current exception being the createdAt field.

  • firstName and lastName: forbiddenSubstrings should be enforced.
  • phoneNumber: forbiddenSubstrings are optional depending on if your validation requires phoneNumber to be a landline.
  • dateOfBirth: only the YYYY-MM-DD format is validated by this package. Semantic checks such as "must be in the past" or age-based rules (e.g. 18+) are intentionally out of scope and must be applied by consumers on top of this foundation.

Limitations

  • The regular expressions are written to be language agnostic, but they have only been tested in TypeScript applications.
  • The regular expressions are compatible with AWS tools that allow regular expressions for string comparison, such as Step Functions, since allowed regex in AWS have some limitations.

Transformations

[!IMPORTANT] The following data transformation must be handled by the products, as they is not included in the validations package to minimise friction to the user journey.

firstName

  • remove whitespace before or after a hyphen or an apostrophe, e.g. " - " is converted to "-"
  • must be in Proper Case

lastName

  • remove whitespace before or after a hyphen or an apostrophe, e.g. " - " is converted to "-"

email

  • must be in lowercase

phoneNumber / mobileNumber

  • remove whitespace

address lines

  • replace comma with space
  • must be no duplicates across lines

postcode

  • must be UPPERCASE