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

@likg/validator

v1.0.9

Published

验证库

Downloads

168

Readme

概述

本库提供常用正则表达式验证

使用

  1. 安装
$ npm install @likg/validator
# OR
$ yarn add @likg/validator
# OR
$ pnpm i @likg/validator
  1. 使用
import Validator from 'lg-validator';
if (Validator.ios()) {
	console.log('iOS环境');
}
if (Validator.tel('17398888669')) {
	console.log('手机号验证通过');
}

API

/**
 * 中文名校验
 * @param v
 */
static isUsername(v: string): boolean;
/**
 * 身份证校验
 * @param v
 */
static isIdCard(v: string): boolean;
/**
 * 验证微信号
 * 1. 可使用6-20个字母、数字、下划线和减号;
 * 2. 必须以字母开头(字母不区分大小写);
 * 3. 不支持设置中文;
 * @param v
 */
static isWeChatId(v: string): boolean;
/**
 * 验证QQ号
 * @param v
 */
static isQQ(v: string): boolean;
/**
 * 验证邮箱
 * @param v
 */
static isEmail(v: string): boolean;
/**
 * 验证手机号
 * @param v
 */
static isTel(v: string): boolean;
/**
 * 验证手机验证码
 * @param v
 */
static isCode(v: string): boolean;
/**
 * 验证Android环境
 */
static isAndroid(): boolean;
/**
 * 验证iOS环境
 */
static isiOS(): boolean;
/**
 * 验证微信环境
 */
static isWeixin(): boolean;
/**
 * 验证是否是刘海屏
 */
static isBangScreen(): boolean;
/**
 * 判断是否是有效日期
 * @param date
 * @returns
 */
static isValidDate(date: Date): boolean;
/**
 * 判断某个日期是否是今日
 * @param $
 * @returns
 */
static isToday(v: Date | string | number): boolean;
/**
 * 校验目标值是否是一个JSON字符串
 * @param target
 * @returns
 */
static isJSON(target: any): boolean;
/**
 * 检验目标字符串是否包含音频后缀
 * @param src
 */
static isAudio(src: string): boolean;
/**
 * 检验目标字符串是否包含视频后缀
 * @param src
 */
static isVideo(src: string): boolean;
/**
 * 校验文件尺寸/扩展名
 * @param options
 * @returns
 */
static checkFile(options: ICheckFileSize | ICheckFileExtension): boolean;
/**
 * 车牌号校验
 * @param plate
 * @returns
 */
static isLicensePlate(plate: string): boolean;
/**
 * 驾驶证号校验(粗率)
 * @param license
 * @returns
 */
static isDriverLicense(license: string): boolean;
/**
 * 行驶证号校验(粗率)
 * @param license
 * @returns
 */
static isVehicleLicense(license: string): boolean;