UNPKG

guarder

Version:

Guarder provides simple validation logic to reduce clutter with inline guard statements

22 lines 729 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ArgumentError_1 = require("../errors/ArgumentError"); /** * Undefined Guard ensures that the property is not undefined */ class UndefinedGuard { /** * @inheritDoc */ guard(property, errorMessage, error) { const message = errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Property not allowed to be undefined'; if (property === undefined) { if (error) throw new error(message); throw new ArgumentError_1.ArgumentError(message); } return property; } } exports.UndefinedGuard = UndefinedGuard; //# sourceMappingURL=UndefinedGuard.js.map