Smart Currency

Automatically validates, parses, and formats currency input. It handles Persian text, numbers, and formatted strings (mixed).

Validation with Zod

With zToman, users can input amounts in any format, and the system normalizes it into a raw number.

schema.ts
typescript
import * as z from 'zod';
import { zToman } from 'zod-ir';

const PaymentSchema = z.object({
  price: zToman({
    min: 1000,
    max: 50_000_000,
    message: 'Amount must be between 1,000 and 50 Million Tomans.',
  }),
});

UI Utility Functions

Tools for converting raw numbers to Persian text for receipts, and converting mixed text inputs back to raw numbers for storage.

utils.ts
typescript
import { transformToCurrency, numberToText } from 'zod-ir';

console.log(transformToCurrency('2 میلیون و پانصد')); // 2500000
console.log(transformToCurrency('سی صد')); // 300

console.log(numberToText(2500000)); // "دو میلیون و پانصد هزار"