chinese-idcard-birth
v1.0.7
Published
chinese-idcard-birth ===================== - xxxx-xx-xx, 生日输入校验用
Downloads
5
Readme
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