From 5e0e1a91e1eead2942032545e220e44f24c87dfd Mon Sep 17 00:00:00 2001 From: Alex Korzhikov Date: Wed, 27 Sep 2017 17:25:07 +0200 Subject: [PATCH] docs(env): Add environment section to describe options --- README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cbc9634..154c63b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,16 @@ This is a part of **djv** packages aimed to work with json-schema. Any contributions are welcome. Check [contribution guide](./CONTRIBUTING.md). +**New!!!** + +Since version *1.2.0* `djv` package supports `draft-06`. +The default version is still *draft-04* for the backward compatibility and due to the semantic versioning. +For `draft-06` use a *version* option in [constructor](#constructor) arguments. + +```javascript +const env = new djv({ version: 'draft-06' }); +``` + ## Table of contents * [djv](#title) @@ -21,6 +31,8 @@ Any contributions are welcome. Check [contribution guide](./CONTRIBUTING.md). * [Install](#install) * [Usage](#usage) * [API](#api) + * [Environment](#environment) + * [addSchema](#addSchema) * [addSchema](#addSchema) * [validate](#validate) * [removeSchema](#removeSchema) @@ -52,8 +64,8 @@ There are 2 versions of validator ## Usage ```javascript -var env = new djv(); -var jsonSchema = { +const env = new djv(); +const jsonSchema = { "common": { "properties": { "type": { @@ -77,6 +89,19 @@ env.validate('test#/common', { type: 'custom' }); ## API +### Environment + +To instantiate `djv` environment + +```javascript +const djv = require('djv'); +const env = djv({ + version: 'draft-06', // use json-schema draft-06 + formats: { /*...*/ }, // custom formats @see #addFormat + errorHandler: () => { /*...*/ }, // custom error handler, @see #setErrorHandler +}); +``` + ### addSchema(name: string, schema: object?) -> resolved: object Add a schema to a current djv environment,