metaschema
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

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.

Package Sidebar

Install

npm i metaschema

Homepage

metarhia.com

Weekly Downloads

76

Version

2.2.0

License

MIT

Unpacked Size

34.1 kB

Total Files

22

Last publish

Collaborators

  • timur.shemsedinov
  • aqrln
  • lundibundi
  • belochub
  • nechaido
  • georgoldenb