Comprehensive Form Example

Learn how to combine powerful validators in a single form and take advantage of the Auto-fix digit feature.

The Magic of preprocessNumber

Users often type with keyboards that send non-English digits. By wrapping your validator inside preprocessNumber, all digits are safely converted to English behind the scenes before validation begins.

comprehensive-schema.ts
typescript
import * as z from 'zod';
import {
  zMelliCode,
  zIranianMobile,
  zCardNumber,
  preprocessNumber,
} from 'zod-ir';

export const UserRegistrationSchema = z.object({
  // Auto-converts Persian/Arabic digits before validation
  nationalCode: preprocessNumber(
    zMelliCode({ message: "کد ملی نامعتبر است" })
  ),

  // Strict zero ensures numbers start with 0
  mobile: preprocessNumber(
    zIranianMobile({ strictZero: true })
  ),
  
  card: preprocessNumber(
    zCardNumber({ message: "شماره کارت اشتباه است" })
  ),
});
Zod Form Simulator
National Code
Mobile Number
Bank Card
Parsed Zod OutputpreprocessNumber Active
{
"nationalCode": "..." ❌ Invalid
"mobile": "..." ❌ Invalid
"card": "..." ❌ Invalid
}