Colophon Schema
Schema & Validator for Colophon
Schema Specification
Versions
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 = { ... }
const colophon = await parser(valid)
Example: Invalid Colophon
const parser = require('@colophon/schema')
const invalid = `
version: 2.0
id: my-app
`
parser(invalid)
.then(colophon)
.catch(err => console.error(err.message, err.errors))
}
Credits
Author: Ahmad Nassri •
Github: @project-colophon •
Twitter: @ColophonID