$ npm i egg-idcard --save
// {app_root}/config/plugin.js
exports.idcard = {
enable: true,
package: 'egg-idcard',
};
// {app_root}/config/config.default.js
exports.idcard = {
};
see config/config.default.js for more detail.
this.app.idcard.verify('123456789');
// {"valid":false, "msg":"请检查身份证号码格式是否合法"}
this.app.idcard.verify('330102199001206292');
// {"valid":false, "msg":"身份证号码18位校验位错误"}
this.app.idcard.verify('330102199001206293');
// {"valid":true,"msg":""}
this.app.idcard.info('330102199001206293');
// {"valid":true,"msg":"","area":{"province":{"code":"330000","name":"浙江省"},"city":{"code":"330100","name":"杭州市"},"district":{"code":"330102","name":"上城区"}},"birthday":"19900120","age":29,"gender":"M"}
this.app.idcard.random();
// 330102199001206293
this.app.idcard.area('330102');
// {"province":{"code":"330000","name":"浙江省"},"city":{"code":"330100","name":"杭州市"},"district":{"code":"330102","name":"上城区"}}
this.app.idcard.repair('330102900120629');
// 330102199001206293
Please open an issue here.