microsoft / microsoft/AdaptiveCards
[Feature Request] Validate Adaptive Card Element Objects
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2k
- Forks
- 595
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 1
Description
Problem Statement
Current Adaptive Card validation that returns errors and warnings to the caller happens at parse time. This approach leaves two scenarios unaddressed:
-
If the caller constructs the object in code, the object is never validated, leaving each renderer to make it's own decisions about what happens to invalid elements that get to them.
-
If the caller passes possibly invalid json with the intent to fix it later in code, they may not be able to do that as we will drop elements that are not valid at parse time.
This proposal came out of a discussion of limitations of the design we are planning for Epic #6015.
Proposed solution
Create a Validate() method on card elements that validates the current state of the card. This can then be run by each renderer at runtime, and used to drop the element and return the appropriate errors and warnings. By doing this validation at render time rather than parse time, we support API users constructing their cards in code.
Alternatives or Workarounds
If a caller wants to explicitly force validation, they could run the card through serialize/deserialize.
Each renderer currently can (needs to) validate the element itself at render time to ensure it handles missing required properties properly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing renderer validation paths and the serialize/deserialize workaround described in the issue. Determine how validation should apply to card elements constructed in code without dropping invalid parsed elements. Done means renderers can validate the current element state and return the appropriate errors and warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100