fluent-json-schema
Version:
JSON Schema fluent API
31 lines (26 loc) • 650 B
JavaScript
const { BaseSchema } = require('./BaseSchema')
const initialState = {
type: 'boolean'
}
/**
* Represents a BooleanSchema.
* @param {Object} [options] - Options
* @param {StringSchema} [options.schema] - Default schema
* @param {boolean} [options.generateIds = false] - generate the id automatically e.g. #properties.foo
* @returns {StringSchema}
*/
const BooleanSchema = ({ schema = initialState, ...options } = {}) => {
options = {
generateIds: false,
factory: BaseSchema,
...options
}
return {
...BaseSchema({ ...options, schema })
}
}
module.exports = {
BooleanSchema,
default: BooleanSchema
}