/** * Validates an Indonesian license plate number format. * Format: [1-2 letters] [1-4 digits] [1-3 letters] * * @param plate - The plate number string to validate * @returns `true` if valid, `false` otherwise * * @example * ```typescript * validatePlate('B 1234 ABC'); // true * validatePlate('AB 1 CD'); // true * ``` */ declare function validatePlate(plate: string): boolean; /** * Gets the region name from a license plate number. * * @param plate - The plate number * @returns Region name or null if not found */ declare function getRegionFromPlate(plate: string): string | null; /** * Formats a license plate number with spaces (e.g., B 1234 ABC). * * @param plate - The plate number * @returns Formatted plate string */ declare function formatPlate(plate: string): string; /** * Mapping of Indonesian license plate prefixes to their regions. */ declare const PLATE_REGIONS: Record; /** * Error thrown when an invalid vehicle plate is provided to a function. * Extends native Error with a `code` property for programmatic error handling. * * @example * ```typescript * try { * requirePlate('invalid'); * } catch (error) { * if (error instanceof InvalidPlateError) { * console.log(error.code); // 'INVALID_PLATE' * } * } * ``` * * @public */ declare class InvalidPlateError extends Error { readonly code: "INVALID_PLATE"; constructor(message?: string); } /** * Options for masking a license plate. */ interface PlateMaskOptions { /** * Number of characters visible at the start (default: 1). */ visibleStart?: number; /** * Number of characters visible at the end (default: 3). */ visibleEnd?: number; /** * Character to use for masking (default: '*'). */ maskChar?: string; } /** * Information extracted from a valid Indonesian license plate number. * * Contains parsed data including the plate prefix, number, suffix, * type classification, and formatted representation. * * @example * ```typescript * const info: PlateInfo = { * prefix: 'B', * number: '1234', * suffix: 'ABC', * type: 'private', * formatted: 'B 1234 ABC', * isValid: true, * }; * ``` * * @public */ interface PlateInfo { /** * Plate prefix (letters before number). * Indicates the region where the vehicle is registered. */ prefix: string; /** * Plate number (digits). */ number: string; /** * Plate suffix (letters after number, if any). */ suffix: string; /** * Type of vehicle registration. * - 'private': Private vehicle * - 'public': Public transportation * - 'diplomat': Diplomatic vehicle * - `null`: Unknown or invalid type */ type: 'private' | 'public' | 'diplomat' | null; /** * Formatted plate string with proper spacing. * @example 'B 1234 ABC' */ formatted: string; /** * Whether the plate passed validation. * If `false`, other fields may contain partial data. */ isValid: boolean; } /** * Parses an Indonesian license plate number into its component parts. * * Extracts the prefix (region code), number, and suffix (optional letters) * from a plate number. Also determines the plate type and returns a * formatted representation. * * @param plate - The plate string to parse * @returns PlateInfo object with extracted components, or null if invalid * * @example * Private plate: * ```typescript * parsePlate('B 1234 ABC'); * // { * // prefix: 'B', * // number: '1234', * // suffix: 'ABC', * // type: 'private', * // formatted: 'B 1234 ABC', * // isValid: true * // } * ``` * * @example * Public transport plate: * ```typescript * parsePlate('AB 1 CD'); * // { * // prefix: 'AB', * // number: '1', * // suffix: 'CD', * // type: 'public', * // formatted: 'AB 1 CD', * // isValid: true * // } * ``` * * @example * Invalid plate returns null: * ```typescript * parsePlate('invalid'); * // null * ``` * * @public */ declare function parsePlate(plate: string): PlateInfo | null; /** * Masks a license plate number for privacy. * * By default, shows 1 character at start and 3 at end, masking the middle. * Returns the masked cleaned string (without spaces). * * @param plate - The license plate to mask * @param options - Mask options (visibleStart, visibleEnd, maskChar) * @returns Masked plate string, or empty string if invalid * * @example * Default masking: * ```typescript * maskPlate('B 1234 ABC'); // 'B****ABC' * maskPlate('DA 1234 T'); // 'DA****T' * ``` * * @example * Custom visibility: * ```typescript * maskPlate('B 1234 ABC', { visibleStart: 2 }); // 'B1***ABC' * maskPlate('B 1234 ABC', { visibleEnd: 4 }); // 'B***4ABC' * ``` * * @example * Custom mask character: * ```typescript * maskPlate('B 1234 ABC', { maskChar: '#' }); // 'B####ABC' * ``` * * @example * Empty or invalid input: * ```typescript * maskPlate(''); // '' * maskPlate('invalid'); // '' * ``` * * @public */ declare function maskPlate(plate: string, options?: PlateMaskOptions): string; /** * Cleans a license plate by removing all non-alphanumeric characters * and converting to uppercase. * * @param plate - The license plate to clean * @returns Cleaned plate string (alphanumeric only, uppercase), or empty string if empty input * * @example * ```typescript * cleanPlate('B 1234 ABC'); // 'B1234ABC' * cleanPlate('da-1234-xyz'); // 'DA1234XYZ' * cleanPlate(''); // '' * ``` * * @public */ declare function cleanPlate(plate: string): string; /** * Checks if a license plate is a private vehicle plate. * * Private plates follow the standard format: letters-numbers-letters * (e.g., B 1234 ABC). * * @param plate - The license plate to check * @returns true if valid private plate, false otherwise * * @example * ```typescript * isPrivatePlate('B 1234 ABC'); // true * isPrivatePlate('B 1234 U'); // false (public suffix) * isPrivatePlate('CD 1234 AB'); // false (diplomat) * isPrivatePlate('invalid'); // false * ``` * * @public */ declare function isPrivatePlate(plate: string): boolean; /** * Checks if a license plate is a public transportation plate. * * Public plates typically have specific suffix indicators * (single letters like U, T, H, K, R). * * @param plate - The license plate to check * @returns true if valid public plate, false otherwise * * @example * ```typescript * isPublicPlate('B 1234 U'); // true * isPublicPlate('B 1234 T'); // true * isPublicPlate('B 1234 ABC'); // false (private) * isPublicPlate('invalid'); // false * ``` * * @public */ declare function isPublicPlate(plate: string): boolean; /** * Checks if a license plate is a diplomat plate. * * Diplomat plates start with 'CD', 'CC', or 'KL' prefix. * * @param plate - The license plate to check * @returns true if valid diplomat plate, false otherwise * * @example * ```typescript * isDiplomatPlate('CD 1234 12'); // true * isDiplomatPlate('CC 1234 AB'); // true * isDiplomatPlate('KL 1234 XY'); // true * isDiplomatPlate('B 1234 ABC'); // false * isDiplomatPlate('invalid'); // false * ``` * * @public */ declare function isDiplomatPlate(plate: string): boolean; export { InvalidPlateError, PLATE_REGIONS, type PlateInfo, type PlateMaskOptions, cleanPlate, formatPlate, getRegionFromPlate, isDiplomatPlate, isPrivatePlate, isPublicPlate, maskPlate, parsePlate, validatePlate };