@wocker/utils
Version:
Utils for @wocker
21 lines (20 loc) • 665 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateVolume = void 0;
const messages_1 = require("../messages");
const validateVolume = (value) => {
if (typeof value === "undefined" || value === null || value === "") {
return true;
}
if (typeof value !== "string") {
return messages_1.messages.volume.notAString;
}
if (value.length > 255) {
return messages_1.messages.volume.tooLong;
}
if (!/^[A-Za-z0-9]+(?:[-_]+[A-Za-z0-9]+)*$/.test(value)) {
return messages_1.messages.volume.invalidCharacters;
}
return true;
};
exports.validateVolume = validateVolume;
;