Skip to content

Commit

Permalink
Allow to force a parameter to be asked again
Browse files Browse the repository at this point in the history
[changelog:added]
  • Loading branch information
cdupuis committed Aug 17, 2020
1 parent 0a2e5ea commit f6fb23f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/api/context/parameterPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ParametersObjectValue } from "../registration/ParametersDefinition";
/**
* Object with properties defining parameters. Useful for combination via spreads.
*/
export type ParametersPromptObject<PARAMS, K extends keyof PARAMS = keyof PARAMS> = Record<K, ParametersObjectValue>;
export type ParametersPromptObject<PARAMS, K extends keyof PARAMS = keyof PARAMS> = Record<K, ParametersObjectValue & { force?: boolean }>;

/**
* Factory to create a ParameterPrompt
Expand Down Expand Up @@ -97,6 +97,12 @@ export function commandRequestParameterPromptFactory<T>(ctx: HandlerContext): Pa
const parameterDefinition = newParameters[parameter];
const value = existingParameter.value;

// Force question
if (parameterDefinition.force) {
trigger.parameters = trigger.parameters.filter(p => p.name !== parameter);
requiredMissing = true;
continue;
}
// Verify pattern
if (parameterDefinition.pattern && !!value && !value.match(parameterDefinition.pattern)) {
requiredMissing = true;
Expand Down

0 comments on commit f6fb23f

Please sign in to comment.