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

navy-scheme

v0.0.1

Published

A data scheme verification package

Readme


API

| Methods | Arguments | Return | | :-----: | :-------------------------------------------: | :----------------------------: | | rule | [data, rule, [matchedText, misMatchedText]] | this | | judge | - | [{ status, text, rule },...] |

Rules

| Class | Rule | Description | Example | Match | | :----: | :--------------: | :----------------------------------: | :-----------------------------: | :------------------: | | Public | Required[type] | 不能为空,[type]为空则不做类型检查,type可以为stringnumber | Required or Required string | "String" | | - | Empty | 必须为空 | Empty | null | | - | True | 必须为真,且类型为布尔值 | True | true | | - | Flase | 必须为假,且类型为布尔值 | Flase | false | | Number | more | 必须大于N | Number more: 10 | 11 | | - | less | 必须小于N | Number less: 10 | 9 | | - | equal | 必须等于N | Number equal: 10 | 10 | | - | between | 必须介于min|max之间 | Number between: 5\|10 | 7 | | - | phone | 必须为合法中国手机号 | Number phone | 13000000000 | | - | int | 必须为整数 | Number int | 10 | | - | float | 必须为浮点数 | Number float | 10.1 | | - | multiple | 必须为N的倍数 | Number multiple: 10 | 20 | | - | divisor | 必须为N的因数 | Number divisor: 10 | 5 | | - | positive | 必须为正数 | Number positive | 10 | | - | negative | 必须为负数 | Number negative | -10 | | String | regexp | 必须匹配正则 | String regexp: [regExp] | - | | - | includes | 必须包含字符串 | String includes: [string] | - | | - | equal | 必须相等 | String equal: [string] | - | | - | minLen | 字符串长度必须大于N | String minLen: 5 | 'asahip' | | - | maxLen | 字符串长度必须小于N | String maxLen: 5 | 'luke' | | - | len | 字符串长度必须等于N | String len: 5 | 'asahi' | | - | between | 字符串长度必须介于minLen|maxLen之间 | String between: 5\|7 | 'asahip' | | - | number | 必须为纯数字 | String number | '1024' | | - | uri | 必须为合法URI | String uri | 'github.com' | | - | mail | 必须为合法邮箱地址 | String mail | '[email protected]' | | - | phone | 必须为合法中国手机号 | String phone | '13000000000' | | Date | after | 必须在指定日期后 | Date after: [...] | - | | - | before | 必须在指定日期前 | Date before: [...] | - | | - | between | 必须介于指定日期之间 | Date between: [...]\|[...] | - | | | at | 必须在指定日期 | Date at: [...] | - | | Array | - | 继承上述所有规则 | - | - | | Object | - | 继承上述所有规则 | - | - |

Grammar

 /**
  * 规则语法:
  * [数据类型][空格][规则名][:][规则参数]
  * [规则名]与[规则参数]之间用分号[:]连接
  * [规则]与[规则]之间用与运算符[,]连接
  * 所有关键字忽视大小写
  * 数组和对象支持多维嵌套
  * 
  * 数字: Number [rule]: [value]
  * 字符串: String [rule]: [numberValue], [rule]: [`stringValue`], [rule]: [`regexpValue`]
  * 日期: Date [rule]: [numberValue], [rule]: [`stringValue`]
  */

Example

/** 
 * 数组嵌套检查
 * 数组永远只会参考下标为0的规则
 */
let navy = new Navy()

navy
  .rule([
	[
        { age: 24 }
    ],
    [
        { age: 'Number more: 23' }
    ]
    [
        'matched message',
        'mismatched message'
    ]
  ])

let result = navy.judge()
/** 对象嵌套检查 */
let navy = new Navy()

navy
  .rule([
    {
        name: 'luke',
        age: 24,
        child: [
            { name: 'kim', age: 10 }
        ],
        contact: {
            phone: '13000000000',
            mail: '[email protected]'
        }
    },
    {
        name: 'Required string',
        age: 'Required number',
        child: [
            { name: 'Required String', age: 'Number less: 11' }
        ],
        contact: {
            phone: 'String phone',
            mail: 'String mail'
        }
    },
    [
        'matched message',
        'mismatched message'
    ]
  ])

let result = navy.judge()

License

MIT