1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.validateDimension = void 0;
|
4 | const validateDimension = (amount, nameOfProp, location) => {
|
5 | if (typeof amount !== 'number') {
|
6 | throw new Error(`The "${nameOfProp}" prop ${location} must be a number, but you passed a value of type ${typeof amount}`);
|
7 | }
|
8 | if (isNaN(amount)) {
|
9 | throw new TypeError(`The "${nameOfProp}" prop ${location} must not be NaN, but is NaN.`);
|
10 | }
|
11 | if (!Number.isFinite(amount)) {
|
12 | throw new TypeError(`The "${nameOfProp}" prop ${location} must be finite, but is ${amount}.`);
|
13 | }
|
14 | if (amount % 1 !== 0) {
|
15 | throw new TypeError(`The "${nameOfProp}" prop ${location} must be an integer, but is ${amount}.`);
|
16 | }
|
17 | if (amount <= 0) {
|
18 | throw new TypeError(`The "${nameOfProp}" prop ${location} must be positive, but got ${amount}.`);
|
19 | }
|
20 | };
|
21 | exports.validateDimension = validateDimension;
|