import { AbstractSession , TextUtils , ImperativeExpect , ImperativeError } from "@zowe/imperative" ; import { noSession } from "@zowe/core-for-zowe-sdk" ; export class export class WorkflowValidator { static param { AbstractSession } session memberof public static validateSession ( session ) { ImperativeExpect . toNotBeNullOrUndefined ( session , TextUtils . formatMessage ( noSession . message ) ) ; } static param { string } text param { string } errorMsg memberof public static validateString ( text , errorMsg ) { ImperativeExpect . toNotBeNullOrUndefined ( text , errorMsg ) ; } static param { string } text param { string } errorMsg memberof public static validateNotEmptyString ( text , errorMsg ) { ImperativeExpect . toNotBeEqual ( "" , text , errorMsg ) ; WorkflowValidator . validateString ( text , errorMsg ) ; } static param { string } parameterValue param { string } errorMsg memberof public static validateParameter ( parameterValue , errorMsg ) { const result = /^[^+?&]+$/ . test ( parameterValue ) ; if ( ! result ) { throw new ImperativeError ( { msg : errorMsg } ) ; } } static param { string } userID param { string } errorMsg memberof public static validateOwner ( userID , errorMsg ) { const result = new RegExp ( /^[a-zA-Z0-9#$@]{1,8}$/ ) . test ( userID ) ; ImperativeExpect . toBeEqual ( true , result , errorMsg ) ; } }