schemy

3.3.1 • Public • Published

Docs 📖 · Plugins 🧩 · Changelog 📝 · Donate 💰

Schemy is an extremely simple, lightweight yet powerful schema validation library. Perfect for lightweight-oriented projects like cloud functions where size and speed are key features. It weights less than 18 KB!

Usage

Install using npm: npm install --save schemy. Then, create a schema with the desired properties and their types:

const Schemy = require('schemy');

const characterSchema = new Schemy({
    'name': {
        type: String,
        required: true
    }
});

// Validate against input data
if (!characterSchema.validate(someData)) {
    characterSchema.getValidationErrors(); // => [ 'Missing required property name' ]
}

// You can also validate asynchronously
await Schemy.validate(someData, characterSchema);

Plugins

Schemy can be easily extended with new functionality. For example, this adds a feature to reference properties within the schema.

// Require the plugin
const ReferenceSupport = require('schemy-reference-support');

// Call Schemy.extend() with the plugin or with an array of plugins
Schemy.extend(ReferenceSupport);

new Schemy({
    password: String,
    confirm: Schemy.$ref('password')
});

You can check the whole list of available plugins in the wiki ↗

API

Static methods

Instance methods


Full documentation ↗️

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.3.110latest

Version History

VersionDownloads (Last 7 Days)Published
3.3.110
3.3.00
3.2.40
3.2.30
3.2.20
3.2.10
3.2.00
3.1.10
3.1.00
3.0.61
3.0.50
3.0.40
3.0.30
3.0.20
3.0.10
3.0.00
2.0.00
1.11.01
1.10.00
1.9.01
1.8.10
1.8.00
1.7.00
1.6.30
1.6.20
1.6.10
1.6.00
1.5.30
1.5.20
1.5.10
1.5.00
1.4.20
1.4.10
1.4.00
1.3.20
1.3.10
1.3.00
1.2.00
1.1.30
1.1.20
1.1.10
1.1.00
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i schemy

Weekly Downloads

13

Version

3.3.1

License

MIT

Unpacked Size

17.4 kB

Total Files

3

Last publish

Collaborators

  • aeberdinelli