Live demo
Use a Stripe test number like 4242 4242 4242 4242.
Usage
import { FormControl } from '@angular/forms';
import { WrValidators } from 'ngwr/validators';
const card = new FormControl('', [WrValidators.cardNumber]);
card.setValue('4242 4242 4242 4242'); // Stripe test → valid
card.setValue('1234567890123456'); // bad checksum → { cardNumber: true }Why ngwr provides this
A Luhn checksum catches mistyped card numbers client-side, before a failed payment round-trip. Angular ships nothing for payments and pulling a payments SDK for one check is overkill.
API
| Name | Description | Type | Default |
|---|---|---|---|
signature | Static — drop into a validators array. | ValidatorFn | — |
accepted | 13–19 digits with valid Luhn checksum. Spaces and dashes are stripped before checking. | string | — |
error key | On failure: { cardNumber: true }. Empty value passes. | { cardNumber: true } | — |