Metadata Schema and Interface Definition Language (IDL)


Keywords
interface, definition, metarhia, idl, dsl, schema, metadata, check, database, globalstorage, hacktoberfest, impress, javascript, js, json, meta-edu, metaprogramming, node, nodejs, type, types, validate
License
MIT
Install
npm install metaschema@2.2.0

Documentation

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.