https://github.com/compono/mongalisa-json-schemas
JSON Schemas support for MongaLisa
https://github.com/compono/mongalisa-json-schemas
Last synced: about 1 year ago
JSON representation
JSON Schemas support for MongaLisa
- Host: GitHub
- URL: https://github.com/compono/mongalisa-json-schemas
- Owner: compono
- Created: 2018-09-18T05:01:13.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-11-25T03:01:22.000Z (over 1 year ago)
- Last Synced: 2025-02-08T09:26:14.780Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 438 KB
- Stars: 1
- Watchers: 21
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# MongaLisa JSON Schemas
This package adds JSON Schemas support for records validation in mongalisa
```
npm add @compono/mongalisa-json-schemas
```
## Basic Usage
```js
const mongalisa = require('@compono/mongalisa');
const jsonSchemaSupport = require('@compono/mongalisa-json-schemas');
mongalisa.plugin(jsonSchemaSupport);
plugin(jsonSchemaSupport());
class User {
static schema = {
type: 'object',
properties: {
email: {
type: 'string',
format: 'email'
},
password: {
type: 'string'
}
},
required: ['email', 'password']
};
}
const users = new mongalisa.Controller(User);
const user = await users.create({
email: 'nikolay@rocks.com',
password: 'Ba(k0/\\/!'
});
await users.create({ email: 'hack!' }); // throws ValidationError
```
## Copyright & License
All code in this repository is the property of Compono Pty Ltd.
Copyright (C) 2018 Compono Pty Ltd.