@zowe/cli
Version:
Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.
77 lines • 2.88 kB
JavaScript
;
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const imperative_1 = require("@zowe/imperative");
const WorkflowConstants_1 = require("./WorkflowConstants");
/**
* Class validates parameters for workflows commands.
* @export
* @class WorkflowValidator
*/
class WorkflowValidator {
/**
* Validate session
* @static
* @param {AbstractSession} session - z/OSMF connection info
* @memberof WorkflowValidator
*/
static validateSession(session) {
imperative_1.ImperativeExpect.toNotBeNullOrUndefined(session, imperative_1.TextUtils.formatMessage(WorkflowConstants_1.noSession.message));
}
/**
* Validate supplied parameters
* @static
* @param {string} text - string to check if not null or undefined
* @param {string} errorMsg - message to show in case validation fails
* @memberof WorkflowValidator
*/
static validateString(text, errorMsg) {
imperative_1.ImperativeExpect.toNotBeNullOrUndefined(text, errorMsg);
}
/**
* Validate supplied parameters
* @static
* @param {string} text - string to check if empty
* @param {string} errorMsg - message to show in case validation fails
* @memberof WorkflowValidator
*/
static validateNotEmptyString(text, errorMsg) {
imperative_1.ImperativeExpect.toNotBeEqual("", text, errorMsg);
WorkflowValidator.validateString(text, errorMsg);
}
/**
* Validate supplied string for parameters if there is not value "?" or "&"
* @static
* @param {string} parameterValue - check if the provided parameters does not contain value "?" or "&"
* @param {string} errorMsg - message to show in case validation fails
* @memberof WorkflowValidator
*/
static validateParameter(parameterValue, errorMsg) {
const result = /^[^+?&]+$/.test(parameterValue);
if (!result) {
throw new imperative_1.ImperativeError({ msg: errorMsg });
}
}
/**
* Validate supplied parameter
* @static
* @param {string} userID - string to check if it is valid user ID regarding IBM
* @param {string} errorMsg - message to show in case validation fails
* @memberof WorkflowValidator
*/
static validateOwner(userID, errorMsg) {
const result = new RegExp(/^[a-zA-Z0-9#\$@]{1,8}$/).test(userID);
imperative_1.ImperativeExpect.toBeEqual(true, result, errorMsg);
}
}
exports.WorkflowValidator = WorkflowValidator;
//# sourceMappingURL=WorkflowValidator.js.map