public static Task <bool> ItemNumberValidator(PromptValidatorContext <string> promptContext, CancellationToken cancellationToken) { // check regex var regex = new Regex(@"\d{9}", RegexOptions.IgnoreCase); var match = regex.Match(promptContext.Recognized.Value); if (match.Success) { var id = promptContext.Recognized.Value = match.Value; // lookup item number to verify it exists var item = _client.GetItemById(id); // add to state if (item != null) { return(Task.FromResult(true)); } } return(Task.FromResult(false)); }