Skip to content
/ schm Public

Composable schemas for JavaScript and Node.js


Notifications You must be signed in to change notification settings


Repository files navigation

Build Status Coverage Status

If you find this useful, please don't forget to star ⭐️ the repo, as this will help to promote the project.
Follow me on Twitter and GitHub to keep updated about this project and others.

schm is a library for creating immutable, composable, parseable and validatable (yeah, many *ables) schemas in JavaScript and Node.js. That's highly inspired by functional programming paradigm.

Play with schm on RunKit (click on Clone and edit this document at the bottom and skip login if you want).

const schema = require('schm')

const userSchema = schema({
  name: String,
  age: {
    type: Number,
    min: 18,

  name: 'Haz',
  age: '27',

await userSchema.validate({
  name: 'Jeane',
  age: 10,


// parsed
  name: 'Haz',
  age: 27,

// validate error
    param: 'age',
    value: 10,
    validator: 'min',
    min: 18,
    message: 'age must be greater than or equal 18',

The way you declare the schema object is very similar to mongoose Schemas. So, refer to their docs to learn more.


schm repository is a monorepo managed by lerna. Click on package name to see specific documentation.

Package Version Description
schm NPM version The main package
schm-computed NPM version Adds computed parameters to schemas
schm-express NPM version Express middlewares to handle querystring and response body
schm-koa NPM version Koa middlewares to handle querystring and response body
schm-methods NPM version Adds methods to parsed schema objects
schm-mongo NPM version Parses values to MongoDB queries
schm-translate NPM version Translates values keys to schema keys


When submitting an issue, put the related package between brackets in the title:

[methods] Something wrong is not right # related to schm-methods
[translate] Something right is not wrong # related to schm-translate
Something wrong is wrong # general issue

PRs are welcome. You should have a look at lerna to understand how this repository works.

After cloning the repository, run yarn. That will install all the project dependencies, including the packages ones.

Before submitting a PR:

  1. Make sure to lint the code: yarn lint or lerna run lint;
  2. Make sure tests are passing: yarn test or lerna run test;


MIT © Diego Haz