From 30741ba7db99da62b9cf76cdd57adfba58217571 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Tue, 26 May 2020 03:47:00 +0200 Subject: [PATCH] Initial commit --- .gitignore | 1 + README.md | 5 +++++ example.js | 11 +++++++++++ index.js | 9 +++++++++ package.json | 9 +++++++++ 5 files changed, 35 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 example.js create mode 100644 index.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/README.md b/README.md new file mode 100644 index 0000000..2a7d66b --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# @validatem/required + +Documentation for this module has not been written yet. By the time it reaches 1.0.0, it will have full documentation. + +In the meantime, check out the `example.js` file in the repository for a usage demonstration. diff --git a/example.js b/example.js new file mode 100644 index 0000000..c5e356d --- /dev/null +++ b/example.js @@ -0,0 +1,11 @@ +"use strict"; + +const required = require("./"); +const { validateValue } = require("@validatem/core"); /* FIXME: Add to devDeps */ + +console.log(validateValue(42, [ required ])); // 42 + +console.log(validateValue(null, [ required ])); /* + AggregrateValidationError: One or more validation errors occurred: + - At (root): Required value is missing +*/ diff --git a/index.js b/index.js new file mode 100644 index 0000000..7f53008 --- /dev/null +++ b/index.js @@ -0,0 +1,9 @@ +"use strict"; + +module.exports = { + ___validatem_isSpecial: true, + ___validatem_isRequiredMarker: true, + ___validatem_requiredMarkerVersion: 1, +}; + +module.exports.__modulePath = __dirname; diff --git a/package.json b/package.json new file mode 100644 index 0000000..d012bb5 --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "@validatem/required", + "description": "Marks a field or value as 'required'", + "version": "0.1.0", + "main": "index.js", + "repository": "http://git.cryto.net/validatem/required.git", + "author": "Sven Slootweg ", + "license": "WTFPL OR CC0-1.0" +}