While Slack provides some client-side validation in Slack apps, we recommend that you run input validation based on your app's business logic. For example, Slack displays an error message on an empty required field when you try to submit a form.
Apex SDK for Slack's field-level validation enables you to handle additional checks on your user input, displaying any errors on form submission.
Specify the data type for an input component that's used to automatically validate the format of the element value entered by the user. If validation fails, an error message is displayed.
Using Apex code to validate user input is not yet supported.
Validate Using The Data Type
To validate the input value, use the
type property of the containing
You must specify a
name for the
input component when using the
type property. Otherwise, an error is returned when the view definition is parsed.
textInput does not contain a valid number, user submission is aborted and an error message appears below the input element.
Apex SDK for Slack offers a set of types that describe the expected format of an input value based on the user locale in the Salesforce org.
The currency locale in the Salesforce org determines if a currency input is valid. Currencies are valid with or without a currency symbol or ISO currency code. The numeric value supports grouping separators and decimal symbols depending on the locale.
$1,025.7 is valid when the currency locale is English (US) and
£1,025.7 is valid when the currency locale is English (UK).
To see your org's currency locale, from Setup, click Company Information. On the Company Information page, find the Currency Locale field. The currency local is global and impacts all users on the org.
A valid email follows the pattern
Here are a few examples.
The user locale determines if a number input is valid. For example,
12,345 is valid when the locale is English. But
1.025,7 is valid only if the locale is German or Dutch.
Here are a few examples based on the English locale.
A valid URL includes a protocol followed by the domain name and optional parameters. Unicode domains are not supported.
Supported protocols include
ftps://, and many others like
news:. Anchor links are supported.
Here are a few examples.
These field types are not yet supported.
- Phone number
Validation using Apex code is subject to Slack's three seconds acknowledgement response. Otherwise, the user receives a connection error in the modal. Dependent field validation is not currently supported if it involves a call to Salesforce.