我有一个Formflow对话框,其中的一个属性就是这个...
[Describe("Car Mileage")]
[Prompt("Cool! What's the mileage of the car?")]
[Template(TemplateUsage.NotUnderstood, "Sorry, I didn't understand that mileage value. Can you enter it again please?")]
public string Mileage { get; set; }
暂时忽略[Template(TemplateUsage.NotUnderstood,...
,我会再说一遍。
该对话框是使用以下内容构建的...
var form = builder
.Field(new FieldReflector<CarValuationDialog>(nameof(ValuationOption))
.SetPrompt(new PromptAttribute($"Hi.<br /><br />Are you looking to get a value for a car you're selling, or car you're buying? {{||}}")))
.Field(new FieldReflector<CarValuationDialog>(nameof(RegistrationNumber))
.SetDefine(RegistrationNumberDefinitionMethod))
.Field(new FieldReflector<CarValuationDialog>(nameof(Mileage))
.SetValidate(async (state, value) =>
{
var result = new ValidateResult { IsValid = true, Value = value };
var regex = new Regex("[0-9,]+");
var match = regex.Match((string)value);
if (match.Success)
{
result.IsValid = true;
}
else
{
result.Feedback = "Sorry, I didn't understand that.";
result.IsValid = false;
}
return await Task.FromResult(result);
}))
.Field(
nameof(PreviousOwnerOption),
active: carValuationDialog => carValuationDialog.ValuationOption == ValuationOptions.LookingToSell)
.Field(
nameof(ServiceHistoryOption),
active: carValuationDialog => carValuationDialog.ValuationOption == ValuationOptions.LookingToSell)
.Confirm(Confirmation)
.OnCompletion(GetValuationAndDisplaySummaryToUser);
return form.Build();
这个问题与
有关`Feedback` text not shown in bot conversation
我正在尝试对Mileage
进行验证,因为我已将该属性从int
更改为string
,以便允许自由文本,例如“ 23,456英里”。作为更改数据类型的副作用,当Mileage
的验证失败时,我得到以下信息...
现在不仅可以向用户显示result.Feedback
值(当Mileage
是int
时还没有显示给用户),而且还可以显示原始问题文本显示。
所以我的主要问题是-我该怎么做,以便在验证失败时不向用户显示原始问题提示?
作为旁注,将Mileage
改回int
且验证失败(result.IsValid = false
)时,未显示result.Feedback
,但显示[Template(TemplateUsage.NotUndderstood....
现在显示。因此,似乎属性类型与所显示的验证消息有关。