Socket
Socket
Sign inDemoInstall

metaschema

Package Overview
Dependencies
2
Maintainers
6
Versions
72
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    metaschema

Metadata Schema and Interface Definition Language (IDL)


Version published
Weekly downloads
242
increased by29.41%
Maintainers
6
Created
Weekly downloads
 

Changelog

Source

[2.2.0][] - 2024-03-27

  • Add browser support
  • Rename SchemaError to ValidationResult
  • Update dependencies

Readme

Source

Metaschema

Metadata schema and interface (contract) definition language

ci snyk npm version npm downloads/month npm downloads license

Installation

$ npm install metaschema

Examples

const { Schema } = require('metaschema');

const schema = Schema.from({
  name: {
    first: 'string',
    last: 'string',
    third: '?string',
  },
  age: 'number',
  levelOne: {
    levelTwo: {
      levelThree: { type: 'enum', enum: [1, 2, 3] },
    },
  },
  collection: { array: { array: 'number' } },
});

const data = {
  name: {
    first: 'a',
    last: 'b',
  },
  age: 5,
  levelOne: { levelTwo: { levelThree: 1 } },
  collection: [
    [1, 2, 3],
    [3, 5, 6],
  ],
};

console.log(schema.check(data));

// Output:
// ValidationResult { errors: [], valid: true }

License & Contributors

Copyright (c) 2017-2024 Metarhia contributors. Metaschema is MIT licensed.
Metaschema is a part of Metarhia technology stack.

Keywords

FAQs

Last updated on 27 Mar 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc