You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ajg

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajg

Ajg: Another JSON Schema Generator

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
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

json

FAQs

Package last updated on 15 Jul 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.