PitchHut logo
A unified library for essential financial validations in TypeScript.
Pitch

finprim simplifies financial applications with a single, zero-dependency library for TypeScript. It provides reliable validations for IBANs, card numbers, VAT, and more, ensuring consistent and efficient implementation. Avoid the hassle of fragmented solutions and streamline your fintech development with this fully typed library.

Description

finprim provides essential financial primitives for modern TypeScript applications, offering a straightforward library that supports various financial operations such as IBAN, card, BIC, VAT, routing number validations, and loan calculations—all without external dependencies.

Core Features

  • Unified Validators: Simplify your application by using one library to validate IBANs (for over 80 countries), BIC/SWIFT, UK sort codes, card numbers, EU VAT numbers, and US routing numbers.
  • Loan Calculations: Make loan management easier with EMI calculations and comprehensive amortization schedules.
  • Flexible Formatting: Easily display IBANs, sort codes, account numbers, and formatted currency for multiple locales.
  • Type Safety: Utilize branded TypeScript types to ensure data integrity, preventing invalid data from passing through your application.
  • Framework Integrations: Optionally integrate with Zod schemas, React hooks, and NestJS pipes, enhancing your existing technology stack without extra configuration.
  • Production-Ready: Built with security and performance in mind, including input length guards and type checking, while adhering to zero runtime dependencies for a lightweight footprint.

Usage Examples

Validation

import { validateIBAN } from 'finprim';
const result = validateIBAN('GB29NWBK60161331926819');
// Output: { valid: true, value: 'GB29NWBK60161331926819', formatted: 'GB29 NWBK 6016 1331 9268 19', countryCode: 'GB' }

Formatting

import { formatCurrency } from 'finprim';
const formattedCurrency = formatCurrency(1000.5, 'GBP', 'en-GB');
// Output: '£1,000.50'

Loan Calculation

import { calculateEMI } from 'finprim';
const emi = calculateEMI(100_000, 10, 12); // Monthly payment amount

React Integration

import { useIBANInput } from 'finprim/react';
function PaymentForm() {
  const iban = useIBANInput();
  return <input value={iban.value} onChange={iban.onChange} />;
}

Integration Options

finprim can be imported directly or through additional modules for specific use cases. Choose from:

  • finprim: Core library with essential validators and formatters.
  • finprim/zod: Zod schemas for seamless validation pipelines.
  • finprim/react: React hooks for managing form inputs.
  • finprim/nest: NestJS pipes for input validation.

For further details and advanced usage, refer to the API Reference and explore the roadmap for upcoming features.

0 comments

No comments yet.

Sign in to be the first to comment.