UNPKG

@twg-group/container-manager

Version:

Container management for Docker, Swarm, Kubernetes

29 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IsValidLabels = IsValidLabels; const class_validator_1 = require("class-validator"); function IsValidLabels(validationOptions) { return function (object, propertyName) { (0, class_validator_1.registerDecorator)({ name: 'isValidLabels', target: object.constructor, propertyName: propertyName, options: validationOptions, validator: { validate(value) { if (value === undefined || value === null) return true; if (typeof value !== 'object') return false; return Object.entries(value).every(([key, val]) => { return /^[a-z0-9-_.]+$/.test(key) && typeof val === 'string'; }); }, defaultMessage() { return 'Labels must be an object with keys containing only a-z, 0-9, -, _, . and string values'; }, }, }); }; } //# sourceMappingURL=is-valid-labels.js.map