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

@rxbenefits/constants

v1.0.0

Published

Application-wide constants, configuration, and validation rules for RxBenefits applications

Downloads

4

Readme

@rxbenefits/constants

CI npm version License: MIT

Application-wide constants, configuration, validation rules, and static data for RxBenefits applications.

Installation

npm install @rxbenefits/constants @rxbenefits/types
# or
yarn add @rxbenefits/constants @rxbenefits/types

Note: This package requires @rxbenefits/types as a peer dependency.

Features

  • 📝 Validation Rules - Form validation rules and regex patterns
  • 🔐 Permissions - Application permission constants
  • 🗺️ Data Mappings - States, gender, relationship mappings
  • ⚙️ Configuration - Runtime configuration management
  • 🛣️ Routes - Application routing constants
  • Form Validators - Custom form validation functions

Usage

Configuration

Access runtime configuration values:

import { config } from '@rxbenefits/constants';

// API endpoints
console.log(config.apiUri);
console.log(config.billingApiUri);

// Auth0 configuration
console.log(config.auth0.domain);
console.log(config.auth0.clientId);

// DataDog RUM configuration
console.log(config.datadog.applicationId);
console.log(config.datadog.clientToken);

Validation Rules

Use pre-defined validation rules for forms:

import { validationRules } from '@rxbenefits/constants';

// Use in Ant Design forms
<Form.Item name="email" rules={validationRules.email}>
  <Input placeholder="Email address" />
</Form.Item>

<Form.Item name="firstName" rules={validationRules.firstName}>
  <Input placeholder="First name" />
</Form.Item>

<Form.Item name="zip" rules={validationRules.zip}>
  <Input placeholder="ZIP code" />
</Form.Item>

Form Validators

Use custom validator functions:

import { Int32Validator } from '@rxbenefits/constants';

// Use in Ant Design form rules
const rules = [
  {
    message: 'Person Code must be less than 2147483647',
    validator: Int32Validator,
  },
];

<Form.Item name="personCode" rules={rules}>
  <Input placeholder="Person Code" />
</Form.Item>

Regex Patterns

Validate data with regex patterns:

import {
  SINGLE_EMAIL_PATTERN,
  SSN_PATTERN,
  ZIP_PATTERN,
  NUMBERS_ONLY,
  ALPHA_ONLY,
} from '@rxbenefits/constants';

// Validate email
if (SINGLE_EMAIL_PATTERN.test(email)) {
  console.log('Valid email');
}

// Validate SSN (9 digits, no dashes)
if (SSN_PATTERN.test(ssn)) {
  console.log('Valid SSN');
}

// Validate ZIP code (5 digits or 5+4 format)
if (ZIP_PATTERN.test(zip)) {
  console.log('Valid ZIP');
}

Data Mappings

Use standardized data mappings:

import { stateCodeMapping, genderMapping, relationshipMapping } from '@rxbenefits/constants';

// Use in select dropdowns
<Select options={stateCodeMapping} placeholder="Select state" />

<Select options={genderMapping} placeholder="Select gender" />

<Select options={relationshipMapping} placeholder="Select relationship" />

Permissions

Check user permissions:

import {
  MEMBER_PERMISSIONS,
  INVOICE_PERMISSIONS,
  FILE_PERMISSIONS,
  DEV_PERMISSIONS,
} from '@rxbenefits/constants';

// Check if user has permission
if (userPermissions.includes(MEMBER_PERMISSIONS.EDIT)) {
  // Show edit button
}

if (userPermissions.includes(INVOICE_PERMISSIONS.DOWNLOAD_FINANCIAL)) {
  // Allow invoice download
}

Application Modules

Define application modules:

import { APP_MODULES, KEYSTONE_APP_MODULES } from '@rxbenefits/constants';

console.log(APP_MODULES); // ['Portal', 'Authorization', 'Keystone', 'Evaluate', 'Agent']
console.log(KEYSTONE_APP_MODULES); // ['Keystone']

Numeric Constants

Use standard numeric constants:

import { INT32MAX } from '@rxbenefits/constants';

// Maximum value for 32-bit signed integer
console.log(INT32MAX); // 2147483647

// Use in validation
if (value <= INT32MAX) {
  console.log('Valid INT32');
}

Available Constants

Configuration

  • config - Runtime configuration object

Validation

  • validationRules - Form validation rules
  • Int32Validator - 32-bit integer validator function

Regex Patterns

  • ALPHA_ONLY - Alphabetic characters only
  • ALPHANUMERIC_ONLY - Alphanumeric characters only
  • NUMBERS_ONLY - Numeric characters only
  • NAME_PATTERN - Valid name pattern (allows -, ., ')
  • FULL_NAME_PATTERN - Full name with spaces
  • SINGLE_EMAIL_PATTERN - Email validation
  • SSN_PATTERN - SSN (9 digits, no dashes)
  • ZIP_PATTERN - ZIP code (5 or 5+4 format)
  • MASKED_PHONE_NUMBER_PATTERN - Phone number validation
  • SINGLE_DECIMAL_POINT_PATTERN - Decimal number validation

Data Mappings

  • stateCodeMapping - US states and territories (56 entries)
  • genderMapping - Gender options (M, F, U)
  • relationshipMapping - Family relationships (7 types)

Permissions

  • MEMBER_PERMISSIONS - Member-related permissions
  • INVOICE_PERMISSIONS - Invoice-related permissions
  • FILE_PERMISSIONS - File management permissions
  • DEV_PERMISSIONS - Developer permissions
  • USER_PERMISSIONS - User management permissions

Routes

  • PageRoutes - Application page routes
  • ReactRouterRoutes - React Router paths

Numeric Constants

  • INT32MAX - Maximum 32-bit signed integer (2147483647)

UI Resources

  • TOOLTIPS - UI tooltip content
  • pbmLogoPaths - PBM logo file paths
  • pbmURLs - PBM URLs
  • staticPdfs - Static PDF paths
  • helpContent - Help content paths

Other

  • APP_MODULES - Application module names
  • KEYSTONE_APP_MODULES - Keystone-specific modules
  • selectIdentifiers - Select box identifiers
  • tableQueryPrefixes - Table query prefixes

Breaking Changes from Monorepo

Int32Validator Location Change

In the monorepo, Int32Validator was located in @optimize/utils. It has been moved to @rxbenefits/constants to break a circular dependency.

Before (monorepo):

import { Int32Validator } from '@optimize/utils';

After (npm package):

import { Int32Validator } from '@rxbenefits/constants';

Rationale: The validator depends on INT32MAX constant and causes a circular dependency when in utils. Moving it to constants co-locates it with the constant it depends on.

Development

Setup

git clone https://github.com/RxBenefits/rxbenefits-constants.git
cd rxbenefits-constants
npm install

Scripts

npm run build          # Build the package
npm run build:dev      # Build with source maps
npm run build:watch    # Watch mode for development
npm run clean          # Remove build artifacts
npm run typecheck      # Type check without building
npm run test           # Run test suite
npm run test:watch     # Run tests in watch mode
npm run test:coverage  # Run tests with coverage
npm run lint           # Lint code
npm run lint:fix       # Lint and auto-fix
npm run format         # Format code with Prettier
npm run format:check   # Check formatting
npm run validate       # Run all checks (typecheck, lint, test)

Testing

This package has comprehensive test coverage including:

  • Form validator tests (Int32Validator)
  • Regex pattern validation tests
  • Data mapping validation tests
  • Permission constants tests
  • Configuration tests

Run tests with:

npm test

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes
  4. Run validation: npm run validate
  5. Commit using conventional commits: git commit -m "feat: add new constant"
  6. Push and create a pull request

Commit Message Format

We use Conventional Commits:

<type>(<scope>): <subject>

<body>

<footer>

Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore

License

MIT © RxBenefits

Support

Related Packages