Skip to content

Refactor the option sets interface to support validating optional and dependent options #3884

@waldekmastykarz

Description

@waldekmastykarz

Refactor options sets to:

public optionSets: OptionSet[]  {
  return [ 
     {
         options: ['option1', 'option2'],
         runsWhen: (args) => args.options.option3 !== undefined // dependant
     },
     {
         options: ['option3', 'option4'] // will run always, default         
     },
     {
         options: ['option5', 'option6'],
         runsWhen: (args) => args.options.option5 || args.options.option6 // exclusive + optional options
     }
  ];
} 

The runsWhen property is optional. When not specified, the option set will be validated. When specified, it will evaluate the specified function and validate the option set only when the function returned true.

  • Update interface
  • Fix broken code

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions