# Invalid Range Values (Mobile)

> In iOS apps, a UISlider's maximumValue must be greater than its minimumValue.

Source: https://knowledge.evinced.com/mobile/mobile-validations/invalid-range-values

A `UISlider`'s `maximumValue` must be greater than its `minimumValue`.

The `minimumValue` of a `UISlider` must be lower than its `maximumValue`. When the range is invalid, the slider looks and behaves as if it were disabled, but VoiceOver doesn't announce it as disabled, may announce an invalid value, and cannot adjust it. Don't try to disable a slider by setting an invalid range. If the slider needs to be disabled, set its `isEnabled` property to `false`, so its state is exposed to assistive technologies.

**Note:** This validation applies to iOS `UISlider` only, including a `UISlider` wrapped for SwiftUI with `UIViewRepresentable`. SwiftUI's `Slider` takes a closed range, which cannot have a lower bound greater than its upper bound, so there are no SwiftUI, Android, or cross-platform examples.

## Pass Patterns

### iOS

UIKit

The slider's `minimumValue` is lower than its `maximumValue`.

```swift
let volumeSlider = UISlider()
volumeSlider.accessibilityLabel = "Volume"
volumeSlider.minimumValue = 0
volumeSlider.maximumValue = 100
volumeSlider.value = 50
```

A slider that must be unavailable keeps a valid range and is disabled with `isEnabled`.

```swift
let volumeSlider = UISlider()
volumeSlider.accessibilityLabel = "Volume"
volumeSlider.minimumValue = 0
volumeSlider.maximumValue = 100
volumeSlider.isEnabled = false
```

## Fail Patterns

### iOS

UIKit

The slider's `minimumValue` is greater than its `maximumValue`.

```swift
let volumeSlider = UISlider()
volumeSlider.accessibilityLabel = "Volume"
volumeSlider.minimumValue = 100
volumeSlider.maximumValue = 0
```

The slider's `minimumValue` and `maximumValue` are equal, so there is no range to adjust. Rather use `.isEnabled = false`

```swift
let volumeSlider = UISlider()
volumeSlider.accessibilityLabel = "Volume"
volumeSlider.minimumValue = 0
volumeSlider.maximumValue = 0
```

## Try It Yourself

### Using a screen reader

**New to screen reader testing, or need a refresher?**  
Review this article first: [Practical guides for using screen readers](https://knowledge.evinced.com/a11y-essentials/practical-guides-for-using-screen-readers)

1.  Turn on VoiceOver.
2.  Swipe right or left to move to the slider.
3.  Swipe up and down to adjust the slider's value.

**Expected results:** VoiceOver announces a valid value, swiping up increases it, and swiping down decreases it. If the slider is unavailable, VoiceOver announces it as dimmed.

**Actual results:** The value does not change, VoiceOver announces an invalid value, or the slider behaves as disabled without being announced as dimmed.

### Using developer tools

1.  In Xcode, open **Xcode > Open Developer Tool > Accessibility Inspector**, select the simulator or device, and point at the slider. Check its **Value**, and try its increment and decrement actions.

**Expected results:** The **Value** is valid and changes when you use the increment and decrement actions.

**Actual results:** The **Value** is invalid, or does not change.

## FAQ

**How does this issue relate to 4.1.2 Name, role, value?**

SC 4.1.2 requires the value of every user interface component to be programmatically determinable, and values that users can set to be programmatically settable. With an invalid range, the slider's value cannot be reliably determined or set by assistive technologies, and a slider that is disabled this way does not expose its disabled state.

**Why is this issue marked as Critical?**

With an invalid range, nobody can adjust the slider, and assistive technology users are not told why. They may keep trying to change a value that cannot change, and cannot complete the task that depends on it, so it is rated critical.

## Standards and Regulations

| Standard | Success Criterion | Reference |
| --- | --- | --- |
| WCAG 2.2 | [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) (A) | For all user interface components, the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to assistive technologies. |
| EN 301 549 | [11.4.1.2 Name, Role, Value](https://www.etsi.org/standards/etsi-301-549) | Same as the WCAG text. |
| Section 508 | [1194.21(d)](https://www.federalregister.gov/documents/2018/01/18/2018-00712/section-508-standards-update#d21) | Sufficient information about a user interface element including the identity, operation and state of the element shall be available to assistive technology. When an image represents a program element, the information conveyed by the image must also be available in text. |

## Personas impacted by this issue

-   [Screen Reader](https://knowledge.evinced.com/a11y-essentials/personas#screen-reader)

## Related Issues

-   [accessible-name](https://knowledge.evinced.com/mobile/mobile-validations/accessible-name)
-   [interactable-role](https://knowledge.evinced.com/mobile/mobile-validations/interactable-role)
