const CONSTANTS = require('../constants/WindowsConsts');

class RegExpBuilderHelper {
    static userInputValidationPattern() {
        const { COMMAND_KEYS } = CONSTANTS;
        let pattern = [];

        Object.keys(COMMAND_KEYS).forEach((commandKey) => {
            const posibleValues = COMMAND_KEYS[commandKey].values.join(',');
            pattern.push(`(-[${commandKey}]{1}\\s[${posibleValues}]{1})|(^-[${commandKey}]{1}$)`);
        });

        return new RegExp(pattern.join('|'));
    }
}

module.exports = RegExpBuilderHelper;
