Skip to content
📃 JSON Schema for Colophon
JavaScript
Branch: master
Clone or download
dependabot-preview and ruxandrafed build(deps-dev): bump tap from 14.1.11 to 14.2.5 (#29)
Bumps [tap](https://github.com/tapjs/node-tap) from 14.1.11 to 14.2.5.
- [Release notes](https://github.com/tapjs/node-tap/releases)
- [Commits](tapjs/node-tap@v14.1.11...v14.2.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Latest commit 5f8bacc Jun 24, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github chore(github): clean up dotfiles Feb 18, 2019
schema docs: update the table for `reference` fields (#30) Jun 25, 2019
test
.colophon.yml feat(2.0): simplify schema file format in v2.0 & expose parser & vali… Feb 18, 2019
.editorconfig chore(editorconfig): add .editorconfig Apr 18, 2018
.eslintrc chore(scaffold): update project template Nov 1, 2018
.gitignore chore(git): add .gitignore Apr 18, 2018
.npmrc chore(scaffold): update project template Nov 1, 2018
.releaserc chore(scaffold): update project template Nov 1, 2018
.remarkrc chore(scaffold): update project template Nov 1, 2018
LICENSE chore(scaffold): update project template Nov 1, 2018
README.md style(markdown): correct lint errors Feb 18, 2019
circle.yml build(circle): bump orb version Mar 8, 2019
error.js feat(2.0): simplify schema file format in v2.0 & expose parser & vali… Feb 18, 2019
index.js test(coverage): skip coverage check for irrelevant context Feb 18, 2019
package-lock.json build(deps-dev): bump tap from 14.1.11 to 14.2.5 (#29) Jun 25, 2019
package.json build(deps-dev): bump tap from 12.6.1 to 14.1.11 (#22) May 28, 2019
renovate.json build(renovate): add renovate.json Apr 18, 2018
versions.js feat(2.0): simplify schema file format in v2.0 & expose parser & vali… Feb 18, 2019

README.md

Colophon Schema

License version Build Status

Schema & Validator for Colophon

Schema Specification

Versions

# status
2.0 stable
1.1 deprecated
1.0 deprecated

see an example of this repo's own .colophon.yml...

Install

Available as an npm package for validation purposes, exposes validation helper, and the schema itself (compatible with any JSON Schema validation tool)

npm install @colophon/schema

Usage

const parser = require('@colophon/schema')
const { schema, regex } = require('@colophon/schema/versions/latest')

Referencing older versions

const schemas = require('@colophon/schema/versions')

const { schema, regex } = schemas['1.0']

API

parser(colophon: String | Object): Promise<Object>

Resolves with content as a valid JavaScript Colophon Object Rejects with ColophonError on invalid schema test

Example: Valid Colophon
const parser = require('@colophon/schema')

const valid = { ... } // supply an Object or YAML String

const colophon = await parser(valid)
// colophon is a JavaScript Object (parsed from YAML string, or returned as is)
Example: Invalid Colophon
const parser = require('@colophon/schema')

// invalid
const invalid = `
version: 2.0

id: my-app
`

parser(invalid)
  .then(colophon)
  .catch(err => console.error(err.message, err.errors))
    // invalid colophon content
    // "err.errors" object contains schema errors
    // e.g. "err.errors": [ { message: "should have required property 'contacts'" } ]
    // see https://github.com/epoberezkin/ajv#validation-errors for details
}

Credits


Author: Ahmad Nassri • Github: @project-colophon • Twitter: @ColophonID

You can’t perform that action at this time.