mongodb-stage-validator

0.3.1 • Public • Published

stage-validator

build status

Validates a MongoDB aggregation pipeline stage.

Usage

The main module exposes two functions: accepts(stageStr) and parse(stageStr).

accepts(stageStr)

The accepts(stageStr) function takes a pipeline stage string and returns true if the string is a valid MongoDB pipeline stage, false otherwise.

Example:

var accepts = require('compass-stage-validator').accepts;
var assert = require('assert');
 
assert.ok(accepts('{"$limit": 1}'));
assert.ok(accepts('{"match": {"x": 35}}'));
 
assert.equal(accepts('{"$invalid": "key"}'), false);

Related

License

Apache 2.0

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i mongodb-stage-validator

    Weekly Downloads

    104

    Version

    0.3.1

    License

    Apache-2.0

    Unpacked Size

    848 kB

    Total Files

    11

    Last publish

    Collaborators

    • lerouxb
    • mabaasit
    • satyasinha
    • alena.khineika
    • mcasimir
    • rhysm
    • addaleax
    • gribnoysup
    • aherlihy