Live demo
Usage
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 } | — |