简体   繁体   中英

How to validate input fields in adaptive card bot framework v4 (waterfall model) c#

I have an adaptive card which include the input fields

  1. Name
  2. Phone Number
  3. Email
  4. Address

I want to validate the fields - validation as below

  1. Name - should not empty and min char 5, max char 20
  2. Phone Number - should not empty and only 10 digit
  3. Email - should not empty and all character and format should be xxxx@wert.com
  4. Address - should not empty.

how to validate input field from adaptive card in bot framework v4 in c#? can anyone please help me.Thanks in advance.

There is not an easy way to do validation for an Adaptive Card. The best option would be to use ActivityPrompt with a custom validator.

Basically:

  1. Create an Adaptive Card
  2. Create an ActivityPrompt
  3. Add the Adaptive Card to the Attachments property of your ActivityPrompt
  4. Send the prompt with a custom validator
  5. In the validator, do all of your custom validation.

The reason you need to use ActivityPrompt is because AdaptiveCard input comes back in Activity.Value instead of Activity.Text and ActivityPrompt will let you call validation on the whole activity.

Alternatively, you may find ActivityCardPrompt helpful, but you'll still need to use your own validator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM