import { Component } from '@angular/core';
import { WrInput } from 'ngwr/input';
import { WrValidators } from 'ngwr/validators';
@Component({ imports: [WrInput] })
export class MyComponent {}noWhitespace
Reject a value with a space, tab or any other whitespace.
Installation
Import the class, and @use the entry point in your global styles: without it the component renders unstyled.
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 }API
| Name | Description | Type | Default |
|---|---|---|---|
signature | Add it to a validators array. | ValidatorFn | — |
error key | On failure: { noWhitespace: true }. Empty value passes. | { noWhitespace: true } | — |