npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shencom/utils-validate

v1.1.0

Published

正则校验工具

Downloads

13

Readme

@shencom/utils-validate

正则校验工具

Install

pnpm add @shencom/utils

# or

pnpm add @shencom/utils-validate

Basic Usage

import { ValidatePhone, ValidateURL } from '@shencom/utils';
// import { ValidatePhone, ValidateURL } from '@shencom/utils-validate';

Methods

ValidateURL

  • 说明: 验证链接是否合法
  • 类型: (url: string) => boolean
  • 参数:
    • url: 链接地址
  • 示例:
    ValidateURL('http://google.com/'); // true

ValidateTime

  • 说明: 验证时间格式
  • 类型: (time: string) => boolean
  • 参数:
    • time: 时间
  • 示例:
    ValidateTime('12:00:00'); // true

ValidateIP

  • 说明: 验证 ip 地址
  • 类型: (ip: string) => boolean
  • 参数:
    • ip: ip 地址
  • 示例:
    ValidateIP('192.168.1.2'); // true

ValidatePhone

  • 说明: 验证手机号
  • 类型: (phone: string) => boolean
  • 参数:
    • phone: 手机号
  • 示例:
    ValidatePhone('15659663146'); // true

ValidateChinese

  • 说明: 验证汉字
  • 类型: (Chinese: string) => boolean
  • 参数:
    • Chinese: 字符串
  • 示例:
    ValidateChinese('中国'); // true

ValidateName

  • 说明: 验证只能输入汉字、字母、中间点“·”
  • 类型: (name: string) => boolean
  • 参数:
    • name: 字符串
  • 示例:
    ValidateName('Sc·深圳'); // true

ValidateEmail

  • 说明: 验证邮箱
  • 类型: (email: string) => boolean
  • 参数:
    • email: 邮箱地址
  • 示例:
    ValidateEmail('[email protected]'); // true

ValidateTel

  • 说明: 验证座机电话
  • 类型: (tel: string) => boolean
  • 参数:
    • tel: 座机电话
  • 示例:
    ValidateTel('0755-2345673'); // true

ValidateCode

  • 说明: 验证邮政编码
  • 类型: (code: string) => boolean
  • 参数:
    • code: 邮政编码
  • 示例:
    ValidateCode('518000'); // true

ValidatePassword

  • 说明: 验证密码 (以字母开头,长度在 6~18 之间,只能包含字母、数字和下划线)
  • 类型: (password: string) => boolean
  • 参数:
    • password: 密码
  • 示例:
    ValidatePassword('sc123123'); // true

ValidateBirthday

  • 说明: 验证出生日期
  • 类型: (birthday: string | number) => boolean
  • 参数:
    • birthday: 出生日期
  • 示例:
    ValidateBirthday('20220221'); // true

ValidateIdCard

  • 说明: 验证身份证 (18 位身份证号码(数字、字母 x 结尾))
  • 类型: (idCardNo: string) => boolean
  • 参数:
    • idCardNo: 身份证号码
  • 示例:
    ValidateIdCard('320482****1119710X'); // true

ValidateHKCard

  • 说明: 验证港澳通行证

  • 类型: (card: string) => boolean

  • 参数:

    • card: 港澳通行证
  • 示例:

    ValidateHKCard('H1234567890'); // true

    ValidateHKIdcard

  • 说明: 验证香港身份证

  • 类型: (idCard: string) => boolean

  • 参数:

    • idCard: 香港身份证
  • 示例:

    ValidateHKIdcard('C123456(9)'); // true

    ValidateMacaoCard

  • 说明: 验证澳门身份证

  • 类型: (idCard: string) => boolean

  • 参数:

    • idCard: 澳门身份证
  • 示例:

    ValidateMacaoCard('5215299(8)'); // true

    ValidateTWCard

  • 说明: 验证台湾身份证

  • 类型: (idCard: string) => boolean

  • 参数:

    • idCard: 台湾身份证
  • 示例:

    ValidateTWCard('Z279587021'); // true

    ValidatePassPortCard

  • 说明: 验证护照号

  • 类型: (idCard: string) => boolean

  • 参数:

    • idCard: 护照号
  • 示例:

    ValidatePassPortCard('G12345678'); // true