# valmo

> A JSON middleware validator for express.

Latest version **0.0.6** (published 2020-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install valmo
pnpm add valmo
yarn add valmo
bun add valmo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2020-03-12 |
| First published | 2020-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | dequilla |
| Maintainers | dequilla |
| Keywords | valmo, express, json, validator |

## Links

- npm: https://www.npmjs.com/package/valmo
- Homepage: https://gitlab.com/Dequilla/valmo
- npm.io page: https://npm.io/package/valmo

## Dependencies (1)

- [ajv](https://npm.io/package/ajv.md) 6.12.0

## Recent versions

- 0.0.6 (latest) — 2020-03-12
- 0.0.5 — 2020-03-12
- 0.0.4 — 2020-03-08
- 0.0.3 — 2020-03-08
- 0.0.2 — 2020-03-08
- 0.0.1 — 2020-03-08

## README

# Valmo
A simple yet powerful way to ensure data validity.

## Content
- [Schema layout](#schema-layout)
- [Getting started](#getting-started)

## Schema layout
Valmo uses the same schema standard as [ajv](https://www.npmjs.com/package/ajv) as this is the validator Valmo uses. It is in turn based on [json-schema.org](http://json-schema.org/). Both have great reasources on how to use schemas.

## Getting started
Example project:
```
// index.js
const valmo = require("valmo")
const express = require("express")

const server = express()
server.use(express.json())
const port = 8080

const schema = require('./userSchema')

server.post(
    '/user',
    valmo.validate(schema, "request.body.user"),
    (request, response) => {
        response
            .status(200)
            .send("That is a valid user!")
            .end()
    }
)

server.listen(port, () => console.log(`Waiting for connections on port ${port}`))

// userSchema.js
module.exports = {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "http://example.org/test.json",

    "title": "User",
    "description": "A user model for a website",
    "type": "object",

    "properties": {
        "username": {
            "description": "User identifier",
            "type": "string"
        },
        "email": {
            "description": "A users personal email",
            "type": "string"
        }
    },
    "required": [
        "username",
        "email"
    ]
};
```

---
_Source: https://npm.io/package/valmo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
