parse(id)
Fully parse ID card information.
Signature
typescript
interface IDCardInfo {
isValid: boolean // whether the ID is valid
provinceCode: string // province code
province: string // province name
birthDate: string // birth date (YYYY-MM-DD)
gender: 'male' | 'female' // gender
age: number // age
fifteenDigit: string | null // 15-digit ID
eighteenDigit: string | null // 18-digit ID
}
function parse(id: string): IDCardInfoParameters
| Parameter | Type | Description |
|---|---|---|
| id | string | ID number |
Returns
Returns an IDCardInfo object with the parsed result.
Live Demo
Example
typescript
import { parse } from 'china-id-card'
const result = parse('622922197808118498')
// {
// isValid: true,
// province: '甘肃省',
// birthDate: '1978-08-11',
// gender: 'male',
// age: 47,
// eighteenDigit: '622922197808118498',
// fifteenDigit: null
// }