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 🙏

© 2026 – Pkg Stats / Ryan Hefner

better-validation

v1.0.6

Published

Collections of validation

Downloads

22

Readme

better-validation

named for my mentor of javascript -- huangyi

What is better-validation?

better-validation is a plugin that collect some useful validation,such as "is this string a legal email address?" you can easily use this and expand your validation through API.

Getting started

Just easily import it.

<script src="path/to/better-validation.js"></script>

<script>
    BValidation.isEmail('[email protected]');//true
    BValidation.isValidDate('2017-02-29');//false
    
    //expand
    BValidation.install('myValidation', function(param){
      return !isNaN(param);
    });
    //use it
    BValidation.myValidation('some thing');//false
</script>

Or import like this.

//some code
import BValidation from 'better-validation';

BValidation.isEmail('[email protected]');//true
### API
```javascript
BValidation.isNumber(param)

check if the type of param is number.

BValidation.isEmail(param)

check if the param is legal email account.

BValidation.isValidAccount(param)

check if the param is legal user account.

the rule is :

length between 4 and 16 included.

letter,number,_,- is required.

BValidation.isUrl(param)

check if the param is legal http,https,ftp or file url.

BValidation.isChnPostcode(param)

check if the param is legal chinese postcode.

BValidation.isTel(param)

check if the param is legal chinese telphone number.

these are allowed:

(021)-12345678

021-12345678

1234567

12345678

BValidation.isMobile(param)

check if the param is legal mobile phone number.

BValidation.isIDCardNo15(param)

check if the param is legal chinese ID card number,which length is 15.

BValidation.isIDCardNo18(param)

check if the param is legal chinese ID card number,which length is 15.

BValidation.isValidPassword(param)

check if the param is legal user password.

the rule is :

length between 6 and 18 included.

letter,number,_ is required

BValidation.isChineseOnly(param)

check if the param contains chinese character only.

BValidation.isChineseContains(param)

check if the param contains chinese character.

BValidation.isHexColor(param)

check if the param is hex color.

BValidation.isQQ(param)

check if the param is legal QQ number.

BValidation.isWX(param)

check if the param is legal WeiXin number.

BValidation.isCarNo(param)

check if the param is legal card number in China.

BValidation.isValidDate(param)

check if the param is legal date.

Such as '2017-02-01' is correct.

'2017-02-29' is incorrect.

BValidation.isIPv4(param)

check if the param is legal IPv4 address.

BValidation.install('name',function)

you can expand the validation through this function.

BValidation.install('myValidation', function(param){
  return !isNaN(param);
});
BValidation.myValidation('lol')//false