-
Notifications
You must be signed in to change notification settings - Fork 85
/
ProvisioningValidator.ts
56 lines (50 loc) · 1.75 KB
/
ProvisioningValidator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* 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.
*
*/
import { AbstractSession, TextUtils, ImperativeExpect } from "@zowe/imperative";
import { noSessionProvisioning } from "./ProvisioningConstants";
/**
* Class validates parameters for provisioning commands.
* @export
* @class ProvisioningValidator
*/
export class ProvisioningValidator {
/**
* Validate session
* @static
* @param {AbstractSession} session - z/OSMF connection info
* @memberof ProvisioningValidator
*/
public static validateSession(session: AbstractSession) {
ImperativeExpect.toNotBeNullOrUndefined(session,
TextUtils.formatMessage(noSessionProvisioning.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 ProvisioningValidator
*/
public static validateString(text: string, errorMsg: string) {
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 ProvisioningValidator
*/
public static validateNotEmptyString(text: string, errorMsg: string) {
ImperativeExpect.toNotBeEqual("", text, errorMsg);
ProvisioningValidator.validateString(text, errorMsg);
}
}