function checkSlug(slug) {
    if (typeof slug !== "string") {
        throw new Error("Slug must be string");
    }

    slug = slug.trim();

    if (!slug) {
        throw new Error("Slug cannot be empty");
    }

    if (!slug.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/)) {
        throw new Error("Invalid Slug");
    }
}
Check slug a-z, 0-9, - only
Regex from: https://stackoverflow.com/questions/22454258/js-regex-string-validation-for-slug
@param {string} slug Slug to test
@returns {void}
@throws Slug is not valid