# cardNumber

> 13–19 digit credit card number with Luhn checksum. Spaces and dashes are stripped before checking. Empty values pass.

Source: https://ngwr.dev/reference/validators/card-number  
Kind: Validator

## Live demo

Use a Stripe test number like `4242 4242 4242 4242`.

## Usage

```angular-ts
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 }` | `—` |

## See also

- [wr-input](https://ngwr.dev/reference/components/input) — Host control for card entry.
- [cvc](https://ngwr.dev/reference/validators/cvc) — Sibling rule for the security code.
- [iban](https://ngwr.dev/reference/validators/iban) — Sibling rule for bank account numbers.
