Skip to content

Instantly share code, notes, and snippets.

@Isaddo
Last active November 24, 2022 07:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Isaddo/e9185573cb3b2df9d0503abd65c2d7ee to your computer and use it in GitHub Desktop.
Save Isaddo/e9185573cb3b2df9d0503abd65c2d7ee to your computer and use it in GitHub Desktop.
用 regular expression 驗證電子發票手機條碼格式 。E-invoice mobile barcode validator by regular expression.
/*
* 第 1 碼為 /
* 其餘 7 碼為 0-9 A-Z . - +
*/
module.exports = (value) => {
// - 需放最後,不然要會跟 0-9 的 - 混淆
const patt = /^\/[0-9A-Z.+-]{7}$/
if (patt.test(value)) return null
return '手機載具碼錯誤'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment