cybertk / csonschema

CSON Schema is a little language that compiles into JSON Schema
MIT License
8 stars 0 forks source link

$schema is the last key in the compiled jsonschema #1

Open cybertk opened 10 years ago

cybertk commented 10 years ago

Given a csonschema like this

name: 'string'
phone_no: 'phoneNumber'
email: 'email'
password: 'string'
verification_code: 'verificationCode'

$required: 'password'

will compiled into

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "phone_no": {
      "type": "string"
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "password": {
      "type": "string"
    },
    "verification_code": {
      "type": "number"
    }
  },
  "required": [
    "password"
  ],
  "additionalProperties": false,
  "$schema": "http://json-schema.org/draft-04/schema"
}