Socket
Book a DemoInstallSign in
Socket

chinese-idcard-birth

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chinese-idcard-birth

chinese-idcard-birth ===================== - xxxx-xx-xx, 生日输入校验用

latest
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

chinese-idcard-birth

  • xxxx-xx-xx, 生日输入校验用

install

  • npm install chinese-idcard-birth

usage

example

const {
    parse,
    unparse,
    CODE_DICT,
    MSG_DICT,
    MD,
    get_random_birth,
    gen,
} = require("chinese-idcard-birth");

> MD
{
  '0': 'success',
  '1': 'length-must-be-8',
  '2': 'must-be-human',
  '3': 'must-between-01-12',
  '4': 'must-between-01-28,29,30,31',
  success: 0,
  'length-must-be-8': 1,
  'must-be-human': 2,
  'must-between-01-12': 3,
  'must-between-01-28,29,30,31': 4
}
> parse("1973")
{ code: 1, msg: {} }
>
> MD[1]
'length-must-be-8'
>
> parse("17001210")
{ code: 2, msg: {} }
> MD[2]
'must-be-human'
>
> parse("19731310")
{ code: 3, msg: { year: 1973 } }
>
> MD[3]
'must-between-01-12'
>

> parse("19730230")
{ code: 4, msg: { year: 1973, month: 2 } }
> MD[4]
'day-must-between-01-28,29,30,31'
>

> parse("19730227")
{ code: 0, rslt: { year: 1973, month: 2, day: 27 } }
>
> MD[0]
'success'
>

> unparse({ year: 1973, month: 2, day: 27 })
'19730227'
>


> get_random_birth({y:1950,m:1,d:1},{y:2050,m:12,d:31})
'20230322'
> get_random_birth({y:1950,m:1,d:1},{y:2050,m:12,d:31})
'19851019'
>

var g = gen(start={y:1950,m:1,d:1},end={y:2050,m:12,d:31})
> g.next()
{ value: '19500101', done: false }
> g.next()
{ value: '19500102', done: false }
> g.next()
{ value: '19500103', done: false }
> g.next()
{ value: '19500104', done: false }
> g.next()
{ value: '19500105', done: false }
> g.next()
{ value: '19500106', done: false }
>

LICENSE

  • ISC

FAQs

Package last updated on 08 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts