microsoft / microsoft/AdaptiveCards

[Input validation] Allow all input values to be included in Action.Submit, even if not associated

Open
#5,392 4 comments 1 reaction 4 assignees View on GitHub

Nobody has claimed this yet.

Epic Request
Dominant language
C#
Stars
2k
Forks
595
Avg merge
1d 19h
Merged PRs (30d)
1

Description

Platforms

  • .NET HTML
  • .NET WPF
  • Android
  • iOS
  • JavaScript
  • UWP

Problems

  • P0: When an Action.Submit's associatedInputs property is set to "none", not only are inputs not validated, their values are also not included in the data property. While this is the desired behavior in most cases, some scenarios call for all input values being included in data even though some or all of those inputs are not validated.
  • P1: associatedInputs should allow for more granularity in terms of which inputs are associated
  • P2: There should be a way to granularly specify which input values should be included in the data property of an Action.Submit

Proposed solutions

IMPORTANT: The below only refers to Action.Submit, but all of the proposed changes also apply to Action.Execute when we introduce it.

P0: Include all input values in data

We will introduce a new includedInputValues property on Action.Submit. Valid values will be "associated" (default) and "all".

  • By default, or when includedInputValues is set to "associated", the current behavior will be maintained (e.g. only the values of the inputs identified via the associatedInputs property are serialized into the data object).
  • When includedInputValues is set to "all", the values of all the inputs in the card are include in the data object
Example

With the below payload, the value of the text input is never included in the data property of the Action.Submit, because its associatedInputs property is set to "none":

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.3",
    "body": [
        {
            "type": "Input.Text",
            "placeholder": "Placeholder text",
            "id": "a",
            "label": "Text input"
        }
    ],
    "actions": [
        {
            "type": "Action.Submit",
            "title": "Submit",
            "associatedInputs": "none"
        }
    ]
}

To fix that using the proposal detailed above, a card author can add the includedInputValues property to the Action.Submit:

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.3",
    "body": [
        {
            "type": "Input.Text",
            "placeholder": "Placeholder text",
            "id": "a",
            "label": "Text input"
        }
    ],
    "actions": [
        {
            "type": "Action.Submit",
            "title": "Submit",
            "associatedInputs": "none"
            "includedInputValues": "all"
        }
    ]
}

P1: Allow card authors to specify exactly which inputs should be validated

We extend the associatedInputs property to accept an array of strings, with each element representing an input Id. Only the inputs specified in the array are validated.

Rules:

  • If an Id doesn't map to any input, it is ignored
  • An empty array is equivalent to "none"
Example

In the card below, only input "a" is validated by the Action.Submit even though input "a" is marked as required:

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.3",
    "body": [
        {
            "type": "Input.Text",
            "placeholder": "Placeholder text",
            "id": "a",
            "isRequired": true,
            "label": "Required, validated:"
        },
        {
            "type": "Input.Text",
            "placeholder": "Placeholder text",
            "id": "b",
            "isRequired": true,
            "label": "Required, NOT validated:"
        }
    ],
    "actions": [
        {
            "type": "Action.Submit",
            "title": "Submit",
            "associatedInputs": [ "a" ]
        }
    ]
}

P2: Allow card authors to specify exactly which input values should be included in data

We extend the proposed submissionInputs property to also accept "associated" to denote "include the values of the associated inputs", or an array of strings, with each item representing an input Id. Only the values of the inputs mentioned in the array are serialized to the data object.

Rules:

  • If an Id doesn't map to any input, it is ignored
  • An empty array forces no values to be serialized to the data object
  • If the property is omitted, it defaults to associated
Example:

In the cars below, only input "b" is validated, however the values of both inputs "a" and "b" are serialized into the data object of the Action.Submit:

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.3",
    "body": [
        {
            "type": "Input.Text",
            "placeholder": "Placeholder text",
            "id": "a",
            "isRequired": true,
            "label": "Input 1:"
        },
        {
            "type": "Input.Text",
            "placeholder": "Placeholder text",
            "id": "b",
            "isRequired": true,
            "label": "Input 2:"
        }
    ],
    "actions": [
        {
            "type": "Action.Submit",
            "title": "Submit",
            "associatedInputs": [ "b" ],
            "submissionInputs": [ "a", "b" ]
        }
    ]
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.