Releases: Edditoria/validid
v3.0.0
The entire codebase is re-written to:
- Catch up the ecosystem of Javascript and NodeJS.
- Provide better experience of LSP and auto-completion.
- More functions and variables for UI.
- Support existing functions in v2, although they will deprecate eventually.
Radical Changes:
- Decaffeinate: Coffeescript → ECMAScript
- JSDoc for your code-editing experience.
- Suppose Typescript LSP should work, too.
- Returns boolean → Returns an object
- Before:
validid.hkid('X') // returns false
. - Now:
validateHkid('X') // returns { ok: false, status: ... }
. - The validation functions returns reason of failure, or simply valid.
- Type definition in 📁
validid/esm/response.mjs
.
- Before:
- One giant object
validid
→ Node's package system- Before:
import validid from 'validid'
. - Now:
import { validateHkid } from 'validid/hkid'
. - Code are grouped using modules, including utils, response and ones for each card type.
- Adapt "conditional exports" of NodeJS's package system.
- For overview, please read "exports" object in 📁
package.json
.
- Before:
- Default export → Named export
- The default exports in v2 are now named export with keyword "validate", e.g.
validateHkid
. - To experience, type the keyword "validate" for auto-completion in common text editors.
- There are some variables and functions in each module. Please search and see the
export
keyword in the code. - For example, the module "hkid" exports
validateHkid
as the core feature of HKID. It also exportsHKID_PATTERN
,HkidStatus
,validateHkidLength
andgetHkidDigit
for your usage.
- The default exports in v2 are now named export with keyword "validate", e.g.
Feature changes:
- The "twid" module
- The Taiwan government launched new numbering format of Resident Certificate to create a friendly environment for foreign nationals living in Taiwan. I believe that the code should reflect this. I am happily support equality in Taiwan.
- Therefore,
validateTwid()
now validate Taiwan NIC and RC together. - You can use
identifyTwidType()
andidentifyTwrcVersion()
after the validation.
- The "krid" module
- The
validateKrid()
does not validate any checksum anymore.
- The
- The "utils" functions are updated as well. Please read the code in 📁
esm/utils.mjs
.
The old functions are deprecated, but they are still available in the codebase in v3.
However, you still need to update your code because those old things will be removed eventually.
In short, you may want to update the code like this:
import { validateHkid } from 'validid/hkid';
const answer = validateHkid(inputId);
const isValid = answer.ok;
For CommonJS, all exports are flattened in a single bundled file:
const { validateHkid } = require('validid'); // Required the bundled UMD file.
const answer = validateHkid(inputId);
const isValid = answer.ok;
Currently there is no plan to build CJS modules, tho.
Thanks for your reading.
May the smoothness be with you!
v2.2.1
v2.2.0
Key change:
- 🆙 Update:
validid.twrc(id)
now validates UID of Taiwan Resident Certificate 2021.
validid.twrc(id)
will validate both new and old format, because the old one will be available until End/2030.
Other things:
- New: Add "get-twrc-format" module for anyone who want to reuse it.
- Update: The outdated twrc method is moved to "twrc-legacy" as a module.
Thanks Taiwan government for improving fairness and better Taiwan living experience. 🍰
v2.1.0
This is a minor update right before another important update about Taiwan Resident Certificate.
- New: Add ESM distribution, so you can import individual module(s) as you need. Please see the
<esm/>
. - Fix: Node 12+ import error by changing file extension of ESM files. Please see the directory
<bundles/>
.
- ❌ Wrong:
'validid/bundles/validid.esm(.min).js'
- ✅ Correct:
'validid/bundles/validid.esm(.min).mjs'
Other things:
- In
<src/>
, add back ".coffee" file extension in all import statements. - Take out
isLengthValid()
in all ID modules. Suppose they are used for returning Error object, but they are useless right now. - Add "is-twid-checksum-valid" module that will be useful in next update.
- Start using Gulp for building ESM and clean up processes.
- Highly recommend to develop this package using Node 14 LTS. (Developers can use lower Node version to "consume" this package, tho.)
- Update and improve a lot of things in development experience. Please see the files in root directory.
v2.0.0
Breaking Changes
⚠️ validid.tools
is renamed tovalidid.utils
. Nothing change on usage ofvalidid.*()
tho.- 2 type of bundles and minify each of them, i.e. 4 files in
<bundles/>
directory. - Source files are managed using ES6 modules. I still ❤️ Coffeescript
- Use Rollup to build, rather than previous dirty bash scripts. Command:
npm run build
Other Things
- Better way to import/require using bundling tools, such as Webpack and Rollup.
- Bower package provides minified version. Happy production!
- Begin to develop using Node 13. Prepare for "conditional exports".