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

5 years ago
"use strict";
const ValidationError = require("@validatem/error");
const isNumberObject = require("./is-number-object");
5 years ago
// 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" });
5 years ago
} else if (Number.isNaN(value)) {
throw new ValidationError(`Must be a number (must not be NaN)`, { code: "validatem.is-number.nan" });
5 years ago
}
};