https://github.com/metarhia/metaschema
Schema definition and validation 💡
https://github.com/metarhia/metaschema
check database dsl globalstorage hacktoberfest impress javascript js json meta-edu metadata metaprogramming metarhia node nodejs schema type types validate
Last synced: about 1 year ago
JSON representation
Schema definition and validation 💡
- Host: GitHub
- URL: https://github.com/metarhia/metaschema
- Owner: metarhia
- License: mit
- Created: 2017-06-22T11:32:52.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-09-22T09:00:20.000Z (over 1 year ago)
- Last Synced: 2025-03-09T05:26:18.229Z (about 1 year ago)
- Topics: check, database, dsl, globalstorage, hacktoberfest, impress, javascript, js, json, meta-edu, metadata, metaprogramming, metarhia, node, nodejs, schema, type, types, validate
- Language: JavaScript
- Homepage: https://metarhia.com
- Size: 984 KB
- Stars: 53
- Watchers: 19
- Forks: 17
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
- Authors: AUTHORS
Awesome Lists containing this project
README
# Metaschema
Metadata schema and interface (contract) definition language
[](https://github.com/metarhia/metaschema/actions?query=workflow%3A%22Testing+CI%22+branch%3Amaster)
[](https://snyk.io/test/github/metarhia/metaschema)
[](https://badge.fury.io/js/metaschema)
[](https://www.npmjs.com/package/metaschema)
[](https://www.npmjs.com/package/metaschema)
[](https://github.com/metarhia/metaschema/blob/master/LICENSE)
## Installation
```bash
$ npm install metaschema
```
## Examples
```js
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](https://github.com/metarhia/metaschema/graphs/contributors).
Metaschema is [MIT licensed](./LICENSE).\
Metaschema is a part of [Metarhia](https://github.com/metarhia) technology stack.