Is your feature request related to a problem? Please describe.
Know the number of attempts in the same validation.
Describe the solution you'd like
PromptValidatorContext should have the number of attempts in the same validation.
Additional context
AddDialog(new TextPrompt(PromptKeys.UserCode, ValidateUserCode))
...
private static async Task<bool> ValidateUserCode(PromptValidatorContext<string> promptContext, CancellationToken cancellationToken)
{
var value = promptContext.Recognized.Value?.Trim() ?? string.Empty;
var regex = @"(CI)[0-9]*";
var match = Regex.Match(value, regex, RegexOptions.IgnoreCase);
if (match.Success)
{
promptContext.Recognized.Value = value;
return true;
}
await promptContext.Context.SendActivityAsync(BotStrings.SharedValidateUserCode);
return false;
}
We have a code similar to this and we want to cancel the dialog after some attempts.
Example:
private static async Task<bool> ValidateUserCode(PromptValidatorContext<string> promptContext, CancellationToken cancellationToken)
{
if (numberOfAttempts > 5) {
// cancel everything
promptContext.EndDialogAsync();
}
var value = promptContext.Recognized.Value?.Trim() ?? string.Empty;
var regex = @"(CI)[0-9]*";
var match = Regex.Match(value, regex, RegexOptions.IgnoreCase);
if (match.Success)
{
promptContext.Recognized.Value = value;
return true;
}
await promptContext.Context.SendActivityAsync(BotStrings.SharedValidateUserCode);
return false;
}
Hey guys,
I'm not sure if I'm missing something here, but I can't find a way to actually leave the validator and end the dialog. @CKGrafico, in you're example you suggest to use "promptContext.EndDialogAsync();" after 5 retries. Actually, the prompt context does not derive form the DialogContext, so the EndDialog method is not available. Is there any other way to get out of the custom validator? If not, what's the point of having an attempt counter? :-)
Could you give me a hint, @johnataylor ?
For anyone who stumbles over the same problem:
https://stackoverflow.com/questions/56790417/leaving-custom-prompt-validation-in-bot-framework-v4
Most helpful comment
For anyone who stumbles over the same problem:
https://stackoverflow.com/questions/56790417/leaving-custom-prompt-validation-in-bot-framework-v4