Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metaschema

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metaschema

Metadata Schema and Interface Definition Language (IDL)

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
183
decreased by-21.46%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 13 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc