metaschema

2019-10-09 admin

metaschema是什么

什么是metaschema,Metadata Schema and Interface Definition Language (IDL)

metaschema使用教程帮助文档

Metaschema

Metadata Schema and Interface Definition Language (IDL)

TravisCI Codacy Badge NPM Version NPM Downloads/Month NPM 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

你可能感兴趣的文章:

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-76955.html

文章标题:metaschema

回到顶部