metaschema

2019-10-09

Metadata Schema and Interface Definition Language (IDL)

Metaschema

Metadata Schema and Interface Definition Language (IDL)

TravisCICodacy BadgeNPM VersionNPM Downloads/MonthNPM Downloads

Installation

$ npm install metaschema

API

class Metaschema

Metaschema.create(schemas, config)

Returns:<Metaschema>

Creates Metaschema object and fills it with schemas

Metaschema.prototype.constructor(config)

Metaschema.prototype.validate(type, schema, instance, options)

  • type: <string>
  • schema: <string>|<Schema>schema or path, that can be resolved by config.resolve
  • instance: <any>
  • options: <Object>

Returns:<Error>|<null>

Validates an instance of a given type against a schema

Metaschema.prototype.create(type, schema, instance, options)

  • type: <string>
  • schema: <string>|<Schema>schema or path, that can be resolved by config.resolve
  • instance: <any>
  • options: <Object>

Returns:<any>

Creates an instance of given schema

Metaschema.prototype.addSchemas(schemas)

  • schemas: <Schema>|<Schema[]>

Adds multiple schemas

async fs.load(dir, options, config)

Returns:<Metaschema>

Creates Metaschema object and fills it with schemas

async fs.applySystemConfig(path, systemConfig, oldConfig)

Returns:newConfig <Object>

Create a config to validate schemas according to the system schema

class default.decorators.classes.ValuesDecorator

default.decorators.classes.ValuesDecorator.prototype.constructor(values)

class default.decorators.classes.Enum extends ValuesDecorator

default.decorators.classes.Enum.prototype.constructor()

class default.decorators.classes.Flags extends ValuesDecorator

default.decorators.classes.Flags.prototype.constructor({ values = [], enumDomain })

default.decorators.classes.Flags.prototype.parse(value)

class default.decorators.classes.Validate

default.decorators.classes.Validate.prototype.constructor(fn)

class default.decorators.classes.List

default.decorators.classes.List.prototype.constructor(def)

default.decorators.functions.Enum(...values)

default.decorators.functions.Flags(...args)

default.decorators.functions.Flags.of(enumDomain)

default.decorators.functions.Validate(fn)

Function decorators

default.decorators.functions.List(def)

default.options.decorators.Validate(fn)

Function decorators

default.options.localDecorators.domains.Enum(...values)

default.options.localDecorators.domains.Flags(...args)

default.options.localDecorators.domains.Flags.of(enumDomain)

default.options.localDecorators.category.List(def)

default.config.prepare(ms)

default.config.resolve(ms, type, name)

default.config.processors.domains.add[0](domains, ms)

default.config.processors.domains.postprocess[0](domains, ms)

default.config.processors.domains.validateInstance(ms, domain, instance, { path = '' } = {})

default.config.processors.category.add[0](category, ms)

default.config.processors.category.postprocess[0](category, ms)

default.config.processors.category.validateInstance(ms, { definition: schema }, instance, options = {})

processSchema(name, source, options, evaluator)

  • name: <string>schema name
  • source: <string>schema source
  • options: <Object>
    • context: <Object>object to be assigned to global during loading
    • decorators: <Object>decorators available during schema processing
    • localDecorators: <Object>type specific decorators available during schema processing
  • evaluator: <Function>function to be used to evaluate schema

Returns:<Object>processed schema

Process schema source

extractDecorator(schema)

Returns:<string>

Extracts schema decorator

extractByPath(definition, path, ms, source)

  • definition: <Object>schema definition in a form similar to category
  • path: <string>path to a a nested property, if it starts with ::substring between ::and .would be treated as category name
  • ms: <Metaschema>
  • source: <string>source for error reporting

Returns:<Object>

Extract definition of a nested property

class errors.SchemaValidationError extends Error

errors.SchemaValidationError.prototype.constructor(type, source, info)

errors.SchemaValidationError.prototype.toString()

class errors.ValidationError extends Error

errors.ValidationError.prototype.constructor(type, property, info)

errors.ValidationError.prototype.toString()

class errors.MetaschemaError extends Error

errors.MetaschemaError.prototype.constructor(errors)

errors.MetaschemaError.prototype.toString()

Contributors

Repository

https://github.com/metarhia/metaschema


上一篇:metasync
下一篇:metastreams
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部