Socket
Socket
Sign inDemoInstall

ajg

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ajg

Ajg: Another JSON Schema Generator


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Install size
6.95 kB
Created
Weekly downloads
 

Readme

Source

Ajg: Another JSON Schema Generator

Build Status

Write your JSON-schemas in simple chainable manner. No plain JSON - no pain.

Quick Start

Install it with NPM or add it to your package.json:

$ npm install ajg

API

ajg.schema

Getter property that creates empty JSON-schema. This schema could be modified by rules in chainable manner:

ajg.schema.required.array.items(ajg.schema.integer)

Produces:

{
    required: true,
    type: 'array',
    items: {
        type: 'integer'
    }
}

Rules

Currently Ajg supports only draft-03 rules and fully compatible with conform.js.

required

ajg.schema.required -> { required: true }

any

ajg.schema.any -> { type: 'any' }

array

ajg.schema.array -> { type: 'array' }

object

ajg.schema.object -> { type: 'object' }

boolean

ajg.schema.boolean -> { type: 'boolean' }

number

ajg.schema.number -> { type: 'number' }

integer

ajg.schema.integer -> { type: 'integer' }

string

ajg.schema.string -> { type: 'string' }

null

ajg.schema.null -> { type: 'null' }

type(type)

ajg.schema.type('array') -> { type: 'array' }

message(message)

ajg.schema.message('hello') -> { message: 'hello' }

messages(messages)

ajg.schema.messages({ required: 'hello' }) -> { messages: { required: 'hello' } }

description(description)

ajg.schema.description('hello') -> { description: 'hello' }

set(key, value)

ajg.schema.set('a', 'b') -> { a: 'b' }

extend(obj1, obj2, ...)

ajg.schema.extend({a: 'b'}) -> { a: 'b' }

reset(key1, key2, ...)

ajg.schema.required.reset('required') -> {}

reset()

ajg.schema.required.reset() -> {}

...

Tests

Clone repository from github, cd into cloned dir and install dev dependencies:

$ npm install

Then run tests with command:

$ npm test

License

MIT

Keywords

FAQs

Last updated on 15 Jul 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc