New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ajv-helper

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv-helper

a helper to convert your config to a ajv schema

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Ajv schema tool

安装

npm i -g ajv-helper

CLI

ajvp -h

Usage: ajvp <command>

Options:
  -V, --version      output the version number
  -h, --help         output usage information

Commands:
  build|b [options]  Build schema json file

生成ajv schema文件

ajvp build

Options:
  -o, --output   指定输出json文件地址

API

addKeyword(String name, Object schema, Function matchFn)

schema: 验证的ajv schema片段 matchFn: 匹配关键字的函数 默认支持3种keyword host: host或hosts结尾的key,value验证为url类型 avatar: avatar或avatars或logo或logos结尾的key,value验证为url类型 email: email或emails结尾的key,value验证为email类型

// demo
const AjvParser = require('ajv-helper')
const ins = new AjvParser()
// host或hosts结尾的key,value应为url格式
ins.addKeyword('host', {
  type: 'string',
  format: 'url'
}, function (str) {
  return /hosts?$/i.test(str)
})
// {"webHost": "xxx"} => {"webHost": {type: 'string', format: 'url'}}
// {"mail": {host: "xxx"}}
//  => 
// {"mail": {
//   type: 'object',
//   properties: {
//     "host": {
//       type: 'string', format: 'url'
//     }
//   }
// }}

Keywords

FAQs

Package last updated on 07 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc