export function validation(element, regex) {
    if (element instanceof HTMLElement && regex instanceof RegExp) {
        element.addEventListener('change', e => {
            if (regex.test(e.target.value)) {
                e.target.classList.remove('validation-error');
            } else {
                e.target.classList.add('validation-error');
            }
        })
    }
    return element;
}

export function convertCssStyle(style) {
    return Object.entries(style).map(s => `${s[0]}: ${s[1]}`).join('; ');
}