commit 748b7467e9186953f94365119f8a43210e00407d Author: Sven Slootweg Date: Fri May 15 18:13:17 2020 +0200 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..cd0b3de --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# virtual-property + +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. + +Rough notes for the future documentation are below: + +---- + +Marker object that is used to denote a 'virtual property' in a path segment for a validation error; a virtual property could be any property that doesn't really exist but that is semantically treated as a separately-checked value within a validator, such as the 'key property' of an `anyProperty` check, or the 'hostname property' of a parsed URL. diff --git a/example.js b/example.js new file mode 100644 index 0000000..f5bdb08 --- /dev/null +++ b/example.js @@ -0,0 +1,13 @@ +"use strict"; + +const virtualProperty = require("./"); + +let property = virtualProperty("propertyName"); + +console.log(property); +/* +{ name: 'propertyName', + ___validatem_isSpecial: true, + ___validatem_isVirtualProperty: true, + ___validatem_virtualPropertyVersion: 1 } +*/ diff --git a/index.js b/index.js new file mode 100644 index 0000000..079598c --- /dev/null +++ b/index.js @@ -0,0 +1,10 @@ +"use strict"; + +module.exports = function virtualProperty(name) { + return { + name: name, + ___validatem_isSpecial: true, + ___validatem_isVirtualProperty: true, + ___validatem_virtualPropertyVersion: 1, + }; +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..9d862ce --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "@validatem/virtual-property", + "description": "Utility for creating an object representing a virtual property", + "version": "0.1.0", + "main": "index.js", + "repository": "http://git.cryto.net/validatem/virtual-property.git", + "author": "Sven Slootweg ", + "license": "WTFPL OR CC0-1.0" +}