@zowe/zos-workflows-for-zowe-sdk
Version:
Zowe SDK to interact with the z/OS workflows APIs
78 lines • 2.91 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 });
exports.WorkflowValidator = void 0;
const imperative_1 = require("@zowe/imperative");
const core_for_zowe_sdk_1 = require("@zowe/core-for-zowe-sdk");
/**
* 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(core_for_zowe_sdk_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