Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SyntaxValidator

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

Private mCommandDefinition

mCommandDefinition: ICommandDefinition

The command definition supplied to validate the arguments against.

Private mDefinitionTree

mDefinitionTree: ICommandDefinition

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

Private mErrorList

mErrorList: ICommandValidatorError[] = []

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

memberof

SyntaxValidator

Private mLogger

mLogger: Logger = Logger.getImperativeLogger()

Get an instance of the logger.

memberof

SyntaxValidator

Private mOptionDefinitionsMap

mOptionDefinitionsMap: any

The full list of command options from the command definition

Static LONG

LONG: string = "--"

Static SHORT

SHORT: string = "-"

Command option short/long

Methods

Private absenceImplicationError

Private appendValidatorError

Private checkIfAllowable

Private emptyValueError

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

Private fileOptionError

Private getDashFormOfOption

  • getDashFormOfOption(optionName: string): string
  • 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

Private getOptionDefinitionFromName

Private implicationAlternativeError

Private invalidJsonString

  • 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

Private missingOptionError

Private missingPositionalParameter

Private mustSpecifyOneError

Private notAnArrayError

Private onlyOneOfError

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

Private optionCombinationInvalidError

Private optionDependencyError

Private positionalParameterInvalid

Private specifiedMultipleTimesError

Private unknownPositionalError

validate

Private validateArrayDuplicate

Private validateBoolean

Private validateNumeric

Private validateOptionValueLength

Private validateOptionValueRange

Private validateSyntax

Private valueRequiresAdditionalOption

Generated using TypeDoc