---
title: Validator
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, PropsTable } from '../../src/components'
import { Validator } from '@telus-uds/components-base'
import { Validator as BaseDocs } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'

# Validator

<LibraryInfo />

```jsx live
<Validator label="Enter your validation code" feedback="Single feedback" />
```

## With Data Masking

```jsx live
<Validator label="Enter your validation code" mask="*" feedback="Single feedback" />
```

## Introduction

Validator can be used for authenticate customers by having them input 6-digit code and provide additional security at login, the behavior is like a text input component, but each cell acts independently.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

Validator will help authenticate customers and provide additional security at login.

### Specifications

- Validator component appears as separated input fields, is semantically a single Input field.
- Display as a 6-digit code.
- Allow copy and paste of the numerical code.
- When the 6-digit code is not complete (you haven't entered all required number of characters/numbers), then allow user to "tab" to the next visual input - not tabbing to the next interactive element.

### Empty state

The default state is empty, hovering over Validator will display the hover state to all empty fields, clickiing anywhere will focus on Validator, focusing or tabing will directo to first empty field.

```jsx live
<Validator label="Enter your validation code" />
```

### Appearance

For example, the fields that are filled, display a success state by default.

```jsx live
<Validator label="Enter your validation code" value="123456" />
```

Validator has no visual variants, but its appearance may change based on the validation and inactive props.

```jsx live
<Validator
  label="Enter your validation code"
  value="123456"
  feedback="Successful feedback"
  validation="success"
/>
```

```jsx live
<Validator
  label="Enter your validation code"
  value="123456"
  feedback="Error feedback"
  validation="error"
/>
```

```jsx live
<Validator label="Enter your validation code" inactive />
```

### Accessibility

- Display Label to provide clarity.
- When hiding Label, please make sure that it is still announced for screen reader users.
- Keep 6-digit code to keep it manageable and reduce cognitive load.
- Allow copy and paste of the numerical code.
- Limit use of a timer to reduce anxiety, stress and cognitive load.

### Platform considerations

<AvailableOnBoth />

## Props

<PropsTable base={BaseDocs} />

## Feedback

<Feedback component="Validator" />
