# noWhitespace

> Reject any space, tab, or other whitespace inside the value. Empty values pass.

Source: https://ngwr.dev/reference/validators/no-whitespace  
Kind: Validator

## Live demo

## Usage

```angular-ts
import { FormControl } from '@angular/forms';
import { WrValidators } from 'ngwr/validators';

const username = new FormControl('', [WrValidators.noWhitespace]);

username.setValue('foo bar');
username.errors; // { noWhitespace: true }
```

## Why ngwr provides this

Angular's `required` happily accepts a string of spaces. This rejects whitespace anywhere in the value without you trimming the model on every keystroke.

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `signature` | Static — drop into a `validators` array. | `ValidatorFn` | `—` |
| `error key` | On failure: `{ noWhitespace: true }`. Empty value passes. | `{ noWhitespace: true }` | `—` |

## See also

- [wr-input](https://ngwr.dev/reference/components/input) — Usernames / handles where stray spaces sneak in.
- [match](https://ngwr.dev/reference/validators/match) — Another cross-field staple for signup forms.
