Helper class for paramter validation. Expectations that fail will throw an ImperativeError with a validation error message.

All methods allow keys to be specified as "property1.prop.lastprop" for example.

export

### Hierarchy

- ImperativeExpect

## Index

### Properties

- ERROR_TAG

### Methods

- arrayToContain
- expectAndTransform
- keysToBeAnArray
- keysToBeDefined
- keysToBeDefinedAndNonBlank
- keysToBeOfType
- keysToBeUndefined
- toBeAnArray
- toBeDefinedAndNonBlank
- toBeEqual
- toBeOneOf
- toMatchRegExp
- toNotBeEqual
- toNotBeNullOrUndefined

## Properties

### Static Readonly ERROR_TAG

ERROR_TAG: string = "Expect Error"

- Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:33

The error tag to append to each error message.

static
memberof

  ImperativeExpect

## Methods

### Static arrayToContain

- arrayToContain(arr: any[], compare: (entry: any) => boolean, msg?: string): any

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:121

  Expect the object passed to be an array that contains a particular entry. Your compare method is invoked to determine if the entry you're looking for is found within the array.

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### arr: any[]

    the array to search

  - ##### compare: (entry: any) => boolean

    compare method (passed the parms) - return true if the entry is found within the array.

    - - (entry: any): boolean

      - #### Parameters

        - ##### entry: any

        #### Returns boolean

  - ##### Optional msg: string

  #### Returns any

  - If a match is found, it will return the match.

### Static expectAndTransform

- expectAndTransform(expect: () => void, transform: (error: any) => ImperativeError): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:48

  Expect a situation and transform the error (if expect fails). Accepts two methods of your implementation to: A) Test the expect (which is intended to throw an ImperativeError) B) Transform and return a new ImperativeError This allows you complete control over the contents of the error. If you are only interested in influencing the message displayed, then use the msg parm on each of the expect functions.

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### expect: () => void

    The method that contains your ImperativeExpect invocation

    - - (): void

      - #### Returns void

  - ##### transform: (error: any) => ImperativeError

    Passed the error thrown by the expect and expects you to return the ImperativeError you would like thrown.

    - - (error: any): ImperativeError

      - #### Parameters

        - ##### error: any

        #### Returns ImperativeError

  #### Returns void

### Static keysToBeAnArray

- keysToBeAnArray(obj: {} | any, nonZeroLength: boolean, keys: string[], msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:180

  Expect a set of keys (by name) to be defined, of type array, and optionally a non-zero length array.

  static

  #### Parameters

  - ##### obj: {} | any

    the object for which you would like to assert that certain fields

  - ##### nonZeroLength: boolean

    if true, the length of the array must be non zero

  - ##### keys: string[]

    keys in object that should be arrays

  - ##### Optional msg: string

  #### Returns void

### Static keysToBeDefined

- keysToBeDefined(obj: {} | any, keys: string[], msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:208

  Expect a set of keys (by name) are defined.

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### obj: {} | any

    object to test existence

  - ##### keys: string[]

    keys in object

  - ##### Optional msg: string

  #### Returns void

### Static keysToBeDefinedAndNonBlank

- keysToBeDefinedAndNonBlank(obj: {} | any, keys: string[], msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:242

  Expect that a set of keys are defined, of type string, and are non-blank (after trimming).

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### obj: {} | any

    object to test existence

  - ##### keys: string[]

    keys in object

  - ##### Optional msg: string

  #### Returns void

### Static keysToBeOfType

- keysToBeOfType(obj: {} | any, type: string, keys: string[], _msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:271

  Expect a set of keys to be of a certain type.

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### obj: {} | any

    The input object

  - ##### type: string

    The type to check for (only primatives - uses "typeof")

  - ##### keys: string[]

    A list of keys to check in the object

  - ##### Optional _msg: string

  #### Returns void

### Static keysToBeUndefined

- keysToBeUndefined(obj: {}, keys: string[], msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:290

  Expect a set of keys to be undefined.

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### obj: {}

    object to test existence

    - ##### [key: string]: any

  - ##### keys: string[]

    keys in object

  - ##### Optional msg: string

  #### Returns void

### Static toBeAnArray

- toBeAnArray(arr: any[], msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:164

  Check if the input object is an array.

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### arr: any[]

    The array to check

  - ##### Optional msg: string

  #### Returns void

### Static toBeDefinedAndNonBlank

- toBeDefinedAndNonBlank(item: string, label: string, msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:254

  #### Parameters

  - ##### item: string

  - ##### label: string

  - ##### Optional msg: string

  #### Returns void

### Static toBeEqual

- toBeEqual(value1: any, value2: any, msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:74

  Expect that values are equal (via "!==" operator).

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### value1: any

    Value 1

  - ##### value2: any

    Value 2

  - ##### Optional msg: string

  #### Returns void

### Static toBeOneOf

- toBeOneOf(value: any, arr: any[], msg?: string): any

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:150

  Check if the input is one of several possibilities in a list.

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### value: any

    The value to find in following array

  - ##### arr: any[]

    The array of possible items we could be expecting

  - ##### Optional msg: string

  #### Returns any

  - If a match is found, it will return the match.

### Static toMatchRegExp

- toMatchRegExp(value: any, myRegex: string, msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:89

  Expect that value matches the regular expression (via ".test()" method).

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### value: any

    Value

  - ##### myRegex: string

    Regular expression

  - ##### Optional msg: string

  #### Returns void

### Static toNotBeEqual

- toNotBeEqual(value1: any, value2: any, msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:227

  Expect two values to be equal (via "===" operator).

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### value1: any

    Value 1

  - ##### value2: any

    Value 2

  - ##### Optional msg: string

  #### Returns void

### Static toNotBeNullOrUndefined

- toNotBeNullOrUndefined(obj: any, msg?: string): void

- - Defined in @zowe/imperative/src/expect/src/ImperativeExpect.ts:103

  Expect the object passed to be defined.

  static
  memberof

    ImperativeExpect

  #### Parameters

  - ##### obj: any

    The object to check

  - ##### Optional msg: string

  #### Returns void

Generated using TypeDoc