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

@esydoc/resolver-validator

v2.1.3

Published

To generate validator code by AST

Downloads

247

Readme

@esydoc/resolver-doc

一个解析 Api 源码生成参数校验的工具

Installation

npm i @esydoc/resolver-validator -D

Usage

esydoc.config.js文件中的resolves字段添加@esydoc/resolver-validator对应的配置就 ok 拉。

// for example in esydoc.config.js
{
  resolves: {
    '@esydoc/resolver-validator': {
      pathPrefix: 'global.hyExt',
      output: {
        template: "validator",
        dist: path.join(__dirname, "validator")
      }
    },
  }
}

Esydoc Extra Config

hostContext

无。

Level

report 等级

  • 1 - 代表 error
  • 0 - 代表 warning

API 配置文件对应配置

所有resolver-doc的配置都在命名空间doc内。

// api config file
{
  validate: {
    // resolver-validator config
  }
}

手动填写部分

  • validate?: ValidateFn[] - 额外的验证函数队列
  • disable?: boolean - 是否取消验证功能
  • level?: number - report 等级,1 - error、0 - warning

特性

@esydoc/resolver-validator会扫描源码 params 的注释,生成参数校验工具代码,校验工具有如下特点:

  1. 会根据你的 params ast 创建一个类型检验函数
  2. 会从 api 配置中拿额外的验证函数
  3. 它们依次的执行顺序为:[ast, ...extra]

验证函数约定

入参

入参透传 SDK 接口调用的实际参数,它是一个数组。

返回值

 返回一个验证结果对象valdatedResult, valdatedResult.pass为枚举值ValidateStatus, valdatedResult.msg为信息。

其中ValidateStatus的枚举值具体分为:Pass = 1UesrPass = 2Fail = -1