Пример #1
0
        public static Task <bool> OrderNumberValidator(PromptValidatorContext <string> promptContext, CancellationToken cancellationToken)
        {
            // check regex - 7 digit number placeholder
            var regex = new Regex(@"\d{7}", RegexOptions.IgnoreCase);

            var match = regex.Match(promptContext.Recognized.Value);

            if (match.Success)
            {
                var id = promptContext.Recognized.Value = match.Value;

                // lookup order number to verify it exists
                var order = _client.GetOrderByNumber(id);

                // add to state
                if (order != null)
                {
                    return(Task.FromResult(true));
                }
            }

            return(Task.FromResult(false));
        }