---
schema_version: "1"
id: b153a195032cbe1e94997ad6ad9dd0eb2d5b8e4baca8bde65b38c2f0f74b8d64
title: Input Validation
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforce-slack-sdk/apex-slack-sdk/guides/build/validation.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/validation.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 5669eada48af37f7eb17f4a0635fbb34d6f3156465559b24c45545ffaf57a633
products:
  - Apex SDK for Slack (Beta)
---
# Input Validation

Slack [modals](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/components/surface.md#modal) provide input validation for elements that are contained in [input components](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/components/layout.md#input). Error messages are displayed when the modal is submitted.

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.

![Required field displays an error](https://developer.salesforce.com/media/validation_required.png)

Apex SDK for Slack's field-level validation enables you to handle additional checks on your user input, displaying any errors on form submission.

## Field-Level Validation

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.

To validate the input value, use the `type` property of the containing `input` component.

```yaml
description: "Validation Test"
components:
  - definition: modal
    properties:
      title: "Create Order"
    components:
      - definition: header
        properties:
          text: "Quantity"
      - definition: input
        name: "number_input" # The optional name for the input type
        properties:
          label: "Number"
          type: "number" # The type used for validation
          required: true
        components:
          - definition: textInput
            properties:
              name: "number"
              placeholder: "Enter a number"
```

If the `textInput` does not contain a valid number, user submission is aborted and an error message appears below the input element.

![Number field displays an error](https://developer.salesforce.com/media/validation_type.png)

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.

- currency
- email
- number
- url

### Currency

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.

For example, `$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.

### Email

A valid email follows the pattern `username@domain.com` or `user.name@domain.com`.

Here are a few examples.

- Valid: `example@domain.com` or `example+group@domain.com`
- Invalid: `example@domain` or `example name@domain.com`

### Number

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.

- Valid: `1.00`, `1,000`, or `1,000.00`
- Invalid: `1.2.3`

### URL

A valid URL includes a protocol followed by the domain name and optional parameters. Unicode domains are not supported.

Supported protocols include `http://`, `https://`, `ftp://`, `ftps://`, and many others like `mailto:` and `news:`. Anchor links are supported.

Here are a few examples.

- Valid: `http://www.salesforce.com` or `https://example.com?testKey=testValue`
- Invalid: `salesforce.com` or `www.salesforce.com`

## Validation Considerations

Using Apex code to validate user input is not yet supported.

Validation using Apex code is subject to Slack's three seconds acknowledgment 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.

These field types are not yet supported.

- Multicurrency
- Geolocation
- Phone number
- Text
