Initial commit
commit
afae22b872
@ -0,0 +1 @@
|
|||||||
|
node_modules
|
@ -0,0 +1,5 @@
|
|||||||
|
# @validatem/is-number
|
||||||
|
|
||||||
|
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.
|
@ -0,0 +1,11 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const { validateValue } = require("@validatem/core"); /* FIXME: Add to devDependencies */
|
||||||
|
const isNumber = require("./");
|
||||||
|
|
||||||
|
console.log(validateValue(42, [ isNumber ])); // hello world
|
||||||
|
|
||||||
|
console.log(validateValue("hello world", [ isNumber ])); /*
|
||||||
|
AggregrateValidationError: One or more validation errors occurred:
|
||||||
|
- At (root): Must be a number
|
||||||
|
*/
|
@ -0,0 +1,14 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const ValidationError = require("@validatem/error");
|
||||||
|
const isNumberObject = require("is-number-object");
|
||||||
|
|
||||||
|
// FIXME: Document that NaN is not permitted but Infinity is
|
||||||
|
|
||||||
|
module.exports = function (value) {
|
||||||
|
if (!isNumberObject(value)) {
|
||||||
|
throw new ValidationError("Must be a number");
|
||||||
|
} else if (Number.isNaN(value)) {
|
||||||
|
throw new ValidationError(`Must not be NaN`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "@validatem/is-number",
|
||||||
|
"description": "Validatem validator for ensuring that a value is a number",
|
||||||
|
"keywords": [
|
||||||
|
"validatem",
|
||||||
|
"validator"
|
||||||
|
],
|
||||||
|
"version": "0.1.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"repository": "http://git.cryto.net/validatem/is-number.git",
|
||||||
|
"author": "Sven Slootweg <admin@cryto.net>",
|
||||||
|
"license": "WTFPL OR CC0-1.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@validatem/error": "^1.0.0",
|
||||||
|
"is-number-object": "^1.0.4"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
"@validatem/error@^1.0.0":
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@validatem/error/-/error-1.0.0.tgz#a975904aa4c3e7618d89088a393567a5e1778340"
|
||||||
|
integrity sha512-7M3tV4DhCuimuCRdC2L/topBByDjhzspzeQGNU0S4/mdn2aDNtESYE43K/2Kh/utCAhqXh2gyw89WYxy//t3fQ==
|
||||||
|
dependencies:
|
||||||
|
create-error "^0.3.1"
|
||||||
|
|
||||||
|
create-error@^0.3.1:
|
||||||
|
version "0.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/create-error/-/create-error-0.3.1.tgz#69810245a629e654432bf04377360003a5351a23"
|
||||||
|
integrity sha1-aYECRaYp5lRDK/BDdzYAA6U1GiM=
|
||||||
|
|
||||||
|
is-number-object@^1.0.4:
|
||||||
|
version "1.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197"
|
||||||
|
integrity sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==
|
Loading…
Reference in New Issue