fignumbers
Version:
A comprehensive TypeScript library for generating figurate numbers across multiple dimensions
56 lines • 1.78 kB
JavaScript
import { CONFIG_CONSTANTS } from "../types/configConstants.js";
import { ERROR_MESSAGE } from "./errorMessages.js";
export class Validator {
static validateStep(step) {
if (step !== undefined) {
if (typeof step !== "bigint") {
throw new Error(ERROR_MESSAGE.stepErrorMessage);
}
if (step <= 0n) {
throw new Error(ERROR_MESSAGE.stepErrorMessage);
}
}
}
static validateStart(start) {
if (start !== undefined) {
if (typeof start !== "bigint") {
throw new Error(ERROR_MESSAGE.startErrorMessage);
}
}
}
static validateMFacets(m) {
if (m !== undefined) {
if (typeof m !== "bigint") {
throw new Error(ERROR_MESSAGE.mFacetsErrorMessage);
}
if (m <= 2n) {
throw new Error(ERROR_MESSAGE.mFacetsErrorMessage);
}
}
}
static validateKDimension(k) {
if (k !== undefined) {
if (typeof k !== "bigint") {
throw new Error(ERROR_MESSAGE.kDimensionErrorMessage);
}
if (k < 4n) {
throw new Error(ERROR_MESSAGE.kDimensionErrorMessage);
}
}
}
static validateConfig(config) {
if (CONFIG_CONSTANTS.step in config) {
this.validateStep(config.step);
}
if (CONFIG_CONSTANTS.start in config) {
this.validateStart(config.start);
}
if (CONFIG_CONSTANTS.m in config) {
this.validateMFacets(config.m);
}
if (CONFIG_CONSTANTS.k in config) {
this.validateKDimension(config.k);
}
}
}
//# sourceMappingURL=Validator.js.map