const Result = require('../types/Result');
const { MESSAGES } = require('../constants/Messages');
const CONSTANTS = require('../constants/WindowsConsts');

class ValidationHelper {
    static isCommandValid(patternMatches) {
        const result = new Result();

        if (!patternMatches || !patternMatches.length) {
            result.isSuccess = false;
            result.error = MESSAGES.ERROR_INVALID_PARAMS;
            return result;
        }

        result.data = patternMatches[0];
        return result;
    }

    static isInputValid(userInput) {
        if (!userInput || userInput.length === 0) {
            return new Result(false, null, MESSAGES.ERROR_NO_PARAMS);
        }

        return new Result();
    }

    static isByNameRemove(component) {
        return CONSTANTS.REMOVE_BY_NAME_COMPONENT.includes(component);
    }
}

module.exports = ValidationHelper;
