UNPKG

cnp-decoder

Version:

A function that decodes a romanian CNP and returns a object containing informations about the person it belongs to

5 lines (4 loc) 239 B
export const validateCNP: (cnp: string) => RegExpMatchArray | null = cnp => { const cnpRegex = /^[1-9]\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])(0[1-9]|[1-4]\d|5[0-2]|99)(00[1-9]|0[1-9]\d|[1-9]\d\d)\d$/ return cnp.match(cnpRegex) }