The Imperative default syntax validator. Accepts the input arguments, command definitions, and a response object. Validates the syntax and issues the appropriate error messages if necessary.

TODO - Consider limiting to a single purpose of producing error documents TODO - that will be outputted by the command processor in a "more structured" TODO - fasion.

export

### Hierarchy

- SyntaxValidator

## Index

### Constructors

- constructor

### Properties

- mCommandDefinition
- mDefinitionTree
- mErrorList
- mLogger
- mOptionDefinitionsMap
- LONG
- SHORT

### Methods

- absenceImplicationError
- appendValidatorError
- checkIfAllowable
- emptyValueError
- fileOptionError
- getDashFormOfOption
- getMustacheSummaryForOption
- getOptionDefinitionFromName
- implicationAlternativeError
- invalidJsonString
- invalidOptionError
- missingOptionError
- missingPositionalParameter
- mustSpecifyOneError
- notAnArrayError
- onlyOneOfError
- optionCombinationInvalidError
- optionDependencyError
- positionalParameterInvalid
- specifiedMultipleTimesError
- unknownPositionalError
- validate
- validateArrayDuplicate
- validateBoolean
- validateNumeric
- validateOptionValueLength
- validateOptionValueRange
- validateSyntax
- valueRequiresAdditionalOption

## Constructors

### constructor

- new SyntaxValidator(commandDefinition: ICommandDefinition, fullCommandDefinition: ICommandDefinition): SyntaxValidator

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:78

  Create the object - maintains the definition used to validate against the input arguments.

  #### Parameters

  - ##### commandDefinition: ICommandDefinition

  - ##### fullCommandDefinition: ICommandDefinition

  #### Returns SyntaxValidator

## Properties

### Private mCommandDefinition

mCommandDefinition: ICommandDefinition

- Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:52

The command definition supplied to validate the arguments against.

### Private mDefinitionTree

mDefinitionTree: ICommandDefinition

- Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:57

The full command definition - which includes the parents of the command.

### Private mErrorList

mErrorList: ICommandValidatorError[] = []

- Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:78

The error list that is appended to the error response object.

memberof

  SyntaxValidator

### Private mLogger

mLogger: Logger = Logger.getImperativeLogger()

- Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:70

Get an instance of the logger.

memberof

  SyntaxValidator

### Private mOptionDefinitionsMap

mOptionDefinitionsMap: any

- Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:62

The full list of command options from the command definition

### Static LONG

LONG: string = "--"

- Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:47

### Static SHORT

SHORT: string = "-"

- Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:46

Command option short/long

## Methods

### Private absenceImplicationError

- absenceImplicationError(optionDef: ICommandOptionDefinition, responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:774

  If an option was specified, some other option should have been specified

  #### Parameters

  - ##### optionDef: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  #### Returns void

### Private appendValidatorError

- appendValidatorError(responseObject: CommandResponse, error: ICommandValidatorError): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:1054

  Append the validator error to the response object.

  #### Parameters

  - ##### responseObject: CommandResponse

  - ##### error: ICommandValidatorError

  #### Returns void

### Private checkIfAllowable

- checkIfAllowable(allowable: ICommandOptionAllowableValues, input: string): boolean

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:571

  Accept the input and check for a match.

  #### Parameters

  - ##### allowable: ICommandOptionAllowableValues

  - ##### input: string

  #### Returns boolean

  : true if the value is allowable.

### Private emptyValueError

- emptyValueError(responseObject: CommandResponse, optionName: string): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:994

  If the user specifies no value for an option that requires a string value, that's an error

  #### Parameters

  - ##### responseObject: CommandResponse

  - ##### optionName: string

  #### Returns void

### Private fileOptionError

- fileOptionError(optionDefinition: ICommandOptionDefinition | ICommandPositionalDefinition, commandArguments: ICommandArguments, responseObject: CommandResponse, isPositional?: boolean): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:493

  Issue the 'file must exist' error

  #### Parameters

  - ##### optionDefinition: ICommandOptionDefinition | ICommandPositionalDefinition

  - ##### commandArguments: ICommandArguments

  - ##### responseObject: CommandResponse

  - ##### Default value isPositional: boolean = false

    is the option a positional option? defaults to false

  #### Returns void

### Private getDashFormOfOption

- getDashFormOfOption(optionName: string): string

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:548

  Get the 'dash form' of an option as it would appear in a user's command, appending the proper number of dashes depending on the length of the option name

  #### Parameters

  - ##### optionName: string

    e.g. my-option

  #### Returns string

  - e.g. --my-option

### Private getMustacheSummaryForOption

- getMustacheSummaryForOption(optionDefinition: ICommandOptionDefinition | ICommandPositionalDefinition, isPositional?: boolean): any

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:515

  Build up an object used for filling in syntax error messages with fields from an option definition

  #### Parameters

  - ##### optionDefinition: ICommandOptionDefinition | ICommandPositionalDefinition

    the option definition to use

  - ##### Default value isPositional: boolean = false

    is the option a positional option? defaults to false

  #### Returns any

  - an object used to replace {{variables}} with mustache

### Private getOptionDefinitionFromName

- getOptionDefinitionFromName(name: string): ICommandOptionDefinition

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:554

  #### Parameters

  - ##### name: string

  #### Returns ICommandOptionDefinition

### Private implicationAlternativeError

- implicationAlternativeError(optionDef: ICommandOptionDefinition, responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:753

  "impliesOneOf" (implicationAlternatives) condition was not satisfied

  #### Parameters

  - ##### optionDef: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  #### Returns void

### Private invalidJsonString

- invalidJsonString(error: Error, optionDefinition: ICommandOptionDefinition, responseObject: CommandResponse, valueSpecified: any): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:474

  Issue an error message indicating that the JSON string provided is not valid.

  #### Parameters

  - ##### error: Error

    the JSON parse try/catch error.

  - ##### optionDefinition: ICommandOptionDefinition

    The Option definition Validate the options. Includes automatic validation based on option and command definition as well as custom validation provided by the user

  - ##### responseObject: CommandResponse

  - ##### valueSpecified: any

  #### Returns void

  : True if the options are valid, false if there is a syntax error

### Private invalidOptionError

- invalidOptionError(failingOption: ICommandOptionDefinition, responseObject: CommandResponse, value: any): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:852

  If the option requires one of a set of values and the value provided doesn't match

  #### Parameters

  - ##### failingOption: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  - ##### value: any

    the value that was specified by the user

  #### Returns void

### Private missingOptionError

- missingOptionError(optionDefinition: ICommandOptionDefinition, responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:588

  Issue the 'option is required' error.

  #### Parameters

  - ##### optionDefinition: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  #### Returns void

### Private missingPositionalParameter

- missingPositionalParameter(missingPositionals: ICommandPositionalDefinition[], responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:1033

  Issue an error message indicating the missing positional parameters

  #### Parameters

  - ##### missingPositionals: ICommandPositionalDefinition[]

    The list of missing positional parameters for the command.

  - ##### responseObject: CommandResponse

  #### Returns void

### Private mustSpecifyOneError

- mustSpecifyOneError(responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:959

  If one of a set of options are required, issue an error message with the list of required options.

  #### Parameters

  - ##### responseObject: CommandResponse

  #### Returns void

### Private notAnArrayError

- notAnArrayError(failingOption: ICommandOptionDefinition, responseObject: CommandResponse, value: any): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:831

  If the option requires one of a set of values and the value provided doesn't match

  #### Parameters

  - ##### failingOption: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  - ##### value: any

    the value specified by the user which was not an array

  #### Returns void

### Private onlyOneOfError

- onlyOneOfError(responseObject: CommandResponse, specified: string[]): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:974

  If more than one of a set of options are specified, issue an error message with the list of offending options

  #### Parameters

  - ##### responseObject: CommandResponse

  - ##### specified: string[]

  #### Returns void

### Private optionCombinationInvalidError

- optionCombinationInvalidError(optionDef1: ICommandOptionDefinition, optionDef2: ICommandOptionDefinition, responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:794

  Issue the options are mutually exclusive error.

  #### Parameters

  - ##### optionDef1: ICommandOptionDefinition

  - ##### optionDef2: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  #### Returns void

### Private optionDependencyError

- optionDependencyError(optionDef1: ICommandOptionDefinition, optionDef2: ICommandOptionDefinition, responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:733

  Issue the options require one another (dependency) error.

  #### Parameters

  - ##### optionDef1: ICommandOptionDefinition

  - ##### optionDef2: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  #### Returns void

### Private positionalParameterInvalid

- positionalParameterInvalid(positionalDefinition: ICommandPositionalDefinition, specified: string, responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:605

  Issue error message indicating that the positional parameter specified does not match the regex.

  #### Parameters

  - ##### positionalDefinition: ICommandPositionalDefinition

  - ##### specified: string

  - ##### responseObject: CommandResponse

  #### Returns void

### Private specifiedMultipleTimesError

- specifiedMultipleTimesError(failingOption: ICommandOptionDefinition, responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:814

  If the option was specified multiple times despite not being an array type option, that's a syntax error

  #### Parameters

  - ##### failingOption: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  #### Returns void

### Private unknownPositionalError

- unknownPositionalError(responseObject: CommandResponse, commandArguments: ICommandArguments, expectedUnderscoreLength: number): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:1010

  If the user specifies an extra positional option

  #### Parameters

  - ##### responseObject: CommandResponse

  - ##### commandArguments: ICommandArguments

  - ##### expectedUnderscoreLength: number

  #### Returns void

### validate

- validate(responseObject: CommandResponse, commandArguments: ICommandArguments): Promise<ICommandValidatorResponse>

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:103

  Validate the command syntax.

  #### Parameters

  - ##### responseObject: CommandResponse

  - ##### commandArguments: ICommandArguments

  #### Returns Promise<ICommandValidatorResponse>

### Private validateArrayDuplicate

- validateArrayDuplicate(optionDefinition: ICommandOptionDefinition, optionValue: string[], responseObject: CommandResponse): boolean

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:694

  Validate if the option's value as array contains duplicates. If yes, error messages will be issued.

  #### Parameters

  - ##### optionDefinition: ICommandOptionDefinition

  - ##### optionValue: string[]

  - ##### responseObject: CommandResponse

  #### Returns boolean

  : false if the value is not valid.

### Private validateBoolean

- validateBoolean(value: any, optionDefinition: ICommandOptionDefinition, responseObject: CommandResponse, isPositional?: boolean): boolean

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:907

  Validate that the option's value is a boolean type

  #### Parameters

  - ##### value: any

  - ##### optionDefinition: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  - ##### Default value isPositional: boolean = false

    is the option a positional option? defaults to false

  #### Returns boolean

### Private validateNumeric

- validateNumeric(value: any, optionDefinition: ICommandOptionDefinition | ICommandPositionalDefinition, responseObject: CommandResponse, isPositional?: boolean): boolean

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:936

  Validate that the option's value is numeric.

  #### Parameters

  - ##### value: any

  - ##### optionDefinition: ICommandOptionDefinition | ICommandPositionalDefinition

  - ##### responseObject: CommandResponse

  - ##### Default value isPositional: boolean = false

    is the option a positional option? defaults to false

  #### Returns boolean

### Private validateOptionValueLength

- validateOptionValueLength(optionDefinition: ICommandOptionDefinition | ICommandPositionalDefinition, optionValue: string, responseObject: CommandResponse, isPositional?: boolean): boolean

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:661

  Validate the that option's value is within the range specified. If not, error messages will be issued.

  #### Parameters

  - ##### optionDefinition: ICommandOptionDefinition | ICommandPositionalDefinition

  - ##### optionValue: string

  - ##### responseObject: CommandResponse

  - ##### Default value isPositional: boolean = false

    is this a positional option? this method works with regular options and positionals

  #### Returns boolean

  : false if the value is not valid.

### Private validateOptionValueRange

- validateOptionValueRange(optionDefinition: ICommandOptionDefinition, optionValue: number, responseObject: CommandResponse): boolean

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:627

  Validate the that option's value is within the range specified. If not, error messages will be issued.

  #### Parameters

  - ##### optionDefinition: ICommandOptionDefinition

  - ##### optionValue: number

  - ##### responseObject: CommandResponse

  #### Returns boolean

  : false if the option's value is not valid.

### Private validateSyntax

- validateSyntax(commandArguments: ICommandArguments, responseObject: CommandResponse): boolean

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:116

  Validate the options. Includes automatic validation based on option and command definition as well as custom validation provided by the user

  #### Parameters

  - ##### commandArguments: ICommandArguments

  - ##### responseObject: CommandResponse

  #### Returns boolean

  : True if the options are valid

### Private valueRequiresAdditionalOption

- valueRequiresAdditionalOption(optionDef: ICommandOptionDefinition, value: string, requires: ICommandOptionDefinition, responseObject: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/syntax/SyntaxValidator.ts:878

  If this option's specification requires another option to be present. e.g. '--type TXT' requires that '--maxlinelength' be specified. That condition was not satisfied, so issue an error message

  #### Parameters

  - ##### optionDef: ICommandOptionDefinition

  - ##### value: string

  - ##### requires: ICommandOptionDefinition

  - ##### responseObject: CommandResponse

  #### Returns void

Generated using TypeDoc