You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
486 B
JavaScript
15 lines
486 B
JavaScript
"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", { code: "validatem.is-number.number" });
|
|
} else if (Number.isNaN(value)) {
|
|
throw new ValidationError(`Must be a number (must not be NaN)`, { code: "validatem.is-number.nan" });
|
|
}
|
|
};
|