yaddle

0.1.2 • Public • Published

yaddle

NPM Version Build Status

Yet Another Data format Description LanguagE

@role: admin | author | collaborator | "role with space"
 
user:
  name: str{3,20}
  age: int{10,200}
  gender: male | female
  roles: [@role]
  description?: str{,200}

translate to json-schema

{
  "type": "object",
  "properties": {
    "user": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 3,
          "maxLength": 20
        },
        "age": {
          "type": "integer",
          "minimum": 10,
          "maximum": 200
        },
        "gender": {
          "enum": [
            "male",
            "female"
          ]
        },
        "roles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/role"
          }
        },
        "description": {
          "type": "string",
          "maxLength": 200
        }
      },
      "required": [
        "name",
        "age",
        "gender",
        "roles"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "user"
  ],
  "additionalProperties": false,
  "definitions": {
    "role": {
      "enum": [
        "admin",
        "author",
        "collaborator",
        "role with space"
      ]
    }
  }
}

api

require("babel/polyfill");
var yaddle = require("yaddle");
yaddle.load("some.ydl").then(...);
 
yaddle.loads(schema).then(...);

more details

see yaddle-py

Keywords

install

npm i yaddle

Downloadsweekly downloads

0

version

0.1.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability