import { Component } from '@angular/core';
import { WrInput } from 'ngwr/input';
import { WrValidators } from 'ngwr/validators';
@Component({ imports: [WrInput] })
export class MyComponent {}hexColor
Check a hex colour such as #abc or #1a2b3c.
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 colour = new FormControl('', [WrValidators.hexColor]);
colour.setValue('#1a2b3c'); // valid
colour.setValue('#xyz'); // { hexColor: true }API
| Name | Description | Type | Default |
|---|---|---|---|
signature | Add it to a validators array. | ValidatorFn | — |
accepted shapes | #abc, #abcd, #a1b2c3, #a1b2c3d4, any case. The # is required. | string | — |
error key | On failure: { hexColor: true }. Empty value passes. | { hexColor: true } | — |