Browse Source

Initial commit

master
Sven Slootweg 2 years ago
commit
437b798064
  1. 1
      .gitignore
  2. 5
      README.md
  3. 11
      index.js
  4. 17
      package.json
  5. 8
      yarn.lock

1
.gitignore

@ -0,0 +1 @@
node_modules

5
README.md

@ -0,0 +1,5 @@
# @validatem/with-context
Documentation for this module has not been fully written yet. By the time it reaches 1.0.0, it will have full documentation.
In the meantime, check out the [`@validatem/allow-extra-properties` module](https://git.cryto.net/validatem/allow-extra-properties) for a usage demonstration.

11
index.js

@ -0,0 +1,11 @@
"use strict";
const combinator = require("@validatem/combinator");
module.exports = function withContext(rules, context) {
return combinator((item, applyValidators, parentContext) => {
let mergedContext = Object.assign({}, parentContext, context);
return applyValidators(item, rules, mergedContext);
});
};

17
package.json

@ -0,0 +1,17 @@
{
"name": "@validatem/with-context",
"description": "Validatem combinator for applying context (custom configuration) to a validator",
"keywords": [
"validatem",
"validator",
"combinator"
],
"version": "0.1.0",
"main": "index.js",
"repository": "http://git.cryto.net/validatem/with-context.git",
"author": "Sven Slootweg <admin@cryto.net>",
"license": "WTFPL OR CC0-1.0",
"dependencies": {
"@validatem/combinator": "^0.1.1"
}
}

8
yarn.lock

@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@validatem/combinator@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@validatem/combinator/-/combinator-0.1.1.tgz#202f31243f8d57cf87f1b449405b134e2fa40c5a"
integrity sha512-crzAYCmKUcb1DC5sSpdof4gWHX81VRmm+REWflhFuRlKH6JHRV5RcBCxEjlDfRrxW2yF6s9i0rQAOyVVE+GGAg==
Loading…
Cancel
Save