hkid
Generate and Validate HKID
![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ftsekityam%2Fhkid.svg?type=shield)
Installation
yarn add hkid
Usage
import * as hkid from "hkid";
random()
generate valid HKID randomly
console.log(hkid.random());
validate(candidate: string, option?: { checkPrefix?: boolean})
validate HKID
-
checkPrefix
: check candidate against the known prefix list. If the prefix of candidate is not in the list, consider it as validation failure. (default: false)
Note: the known prefix list may be incomplete, so false negative may be returned if checkPrefix
is set to true
.
console.log(hkid.validate("H3497811"));
console.log(hkid.validate("h3497811"));
console.log(hkid.validate("H349781(1)"));
console.log(hkid.validate("H3497810"));
console.log(hkid.validate("YK1597716");
console.log(hkid.validate("YK1597716", { checkPrefix: false}));
console.log(hkid.validate("YK1597716", { checkPrefix: true}));
CodeSandbox
References
License
![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ftsekityam%2Fhkid.svg?type=large)