1.0.1 • Published 3 years ago

chinese-social-credit-code v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

chinese-social-credit-code

  • chinese-social-credit-code
  • 统一社会信用码 输入校验用

install

  • npm install chinese-social-credit-code

usage

example

const {
    validate,
    is_social_credit_code,
    MSG_DICT,
    CODE_DICT,
    MD
} = require("chinese-social-credit-code")


> validate("12440300695588698")
{ code: 2, msg: 'length-must-be-18' }
> validate("124403006955886981")
{ code: 3, msg: 'logic-check-code-not-match' }
> validate("124403006955886982")
{ code: 0, msg: 'success' }
>
> is_social_credit_code("124403006955886982")
true
> MSG_DICT
{
  succ: 'success',
  length: 'length-must-be-18',
  char: 'must be 0123456789ABCDEFGHJKLMNPQRTUWXY',
  logic_check_code: 'logic-check-code-not-match'
}
> CODE_DICT
{ succ: 0, char: 1, length: 2, logic_check_code: 3 }
> MD
{
  '0': 'success',
  '1': 'length-must-be-18',
  '2': 'must be 0123456789ABCDEFGHJKLMNPQRTUWXY',
  '3': 'logic-check-code-not-match',
  success: 0,
  'length-must-be-18': 1,
  'must be 0123456789ABCDEFGHJKLMNPQRTUWXY': 2,
  'logic-check-code-not-match': 3
}
>

LICENSE

  • ISC