Im using adaptive cards for scheduling a meeting in teams, I'm unable to validate the content in the card as isRequired is not working. But i have seen documentation stating that isRequired will work.
-
Possible duplicate of [Check if an input form is filled in a Adaptive Card bot framework c#](https://stackoverflow.com/questions/55415796/check-if-an-input-form-is-filled-in-a-adaptive-card-bot-framework-c-sharp) – Kyle Delaney May 08 '19 at 19:24
-
Hello, would you please provide a link to the documentation that says `isRequired` will work? – Kyle Delaney May 08 '19 at 19:25
-
Is my answer acceptable? – Kyle Delaney May 14 '19 at 21:33
-
I'm using teams channel, so once the card is rendered i dont have a control over the data right, so that means in the case of validating from code side i have to render the card again and again. – Elma Sarah Daniel May 16 '19 at 04:44
-
Well your bot doesn't render the card at all. If you mean you have to send the card again and again, you still don't have to. Once the card is in the conversation it can be reused. – Kyle Delaney May 16 '19 at 22:00
-
Here is my case : I fill some fields of a form but completely and click the submit action, the values actually disappears, so is i were to do a validation from the code side the user still has to re enter all the values right else i have to send a pre-filled card. – Elma Sarah Daniel May 17 '19 at 04:29
-
1Oh I see what you mean. Microsoft Teams actually allows you to update messages, so when you validate it on the bot side you could send a message update request with the pre-filled card instead of sending the pre-filled card in additional messages. – Kyle Delaney May 17 '19 at 19:21
2 Answers
There is currently no isRequired
field in adaptive inputs, as can be seen here and here.
You will need to use a workaround depending on your needs and your channel. If you're using a Direct Line client like Web Chat then you'll be able to provide client-side validation, but it won't be easy. Otherwise you'll probably want to validate the input in the bot code, like in the answers to Check if an input form is filled in, in a Adaptive Card and Check if an input form is filled in a Adaptive Card bot framework c#. If you're using a channel that supports message-updating then you can even change the card to indicate to the user what fields they haven't filled out.

- 11,616
- 6
- 39
- 66
If you are going to use adaptive cards a lot in your bot than it makes sense to create card models and have validation attributes applied to each field that needs validation. Create custom card prompt inheriting from Prompt<object>
class. Override OnPromptAsync
and OnRecognizeAsync
and check the validation of each field there.

- 304
- 2
- 11