Skip to content

Releases: Edditoria/validid

v3.0.0

30 Sep 18:37
Compare
Choose a tag to compare

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.
  • 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.
  • 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 exports HKID_PATTERN, HkidStatus, validateHkidLength and getHkidDigit for your usage.

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() and identifyTwrcVersion() after the validation.
  • The "krid" module
    • The validateKrid() does not validate any checksum anymore.
  • 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

12 Mar 17:38
Compare
Choose a tag to compare

Important: Default branch is now "main"!!

Minor update: Test cases, repo configs and npm packages.

v2.2.0

26 Nov 08:44
Compare
Choose a tag to compare

Key change:

  • 🆙 Update: validid.twrc(id) now validates UID of Taiwan Resident Certificate 2021.

⚠️ Important: 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

21 Nov 10:16
Compare
Choose a tag to compare

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/>.

⚠️ Important: For existing developers, please check your import statements about ESM bundle files:

  • ❌ 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

24 Mar 10:16
Compare
Choose a tag to compare

Breaking Changes

  • ⚠️ validid.tools is renamed to validid.utils. Nothing change on usage of validid.*() 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".

v1.2.0

15 Jan 15:37
Compare
Choose a tag to compare
  • New: Added support of HKID starting with "N", since Hong Kong government started to use it for new ID in 2019.
  • Update: Improve code in TWID and TWRC. Thanks for pull request #4 ! 🍕