@twg-group/container-manager
Version:
Container management for Docker, Swarm, Kubernetes
29 lines • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsValidEnvObject = IsValidEnvObject;
const class_validator_1 = require("class-validator");
function IsValidEnvObject(validationOptions) {
return function (object, propertyName) {
(0, class_validator_1.registerDecorator)({
name: 'isValidEnvObject',
target: object.constructor,
propertyName: propertyName,
options: validationOptions,
validator: {
validate(value) {
if (!value)
return true;
if (typeof value !== 'object')
return false;
return Object.entries(value).every(([key, val]) => {
return /^[A-Z_][A-Z0-9_]*$/.test(key) && typeof val === 'string';
});
},
defaultMessage() {
return 'Env keys must be UPPER_CASE with underscores, and values must be strings';
},
},
});
};
}
//# sourceMappingURL=is-valid-env-object.js.map