# cvc

> N digits — typically 3 (Visa/MC/Discover) or 4 (Amex). Empty values pass.

Source: https://ngwr.dev/reference/validators/cvc  
Kind: Validator

## Live demo — 3 digits (Visa / MC)

## Live demo — 4 digits (Amex)

## Usage

```angular-ts
import { FormControl } from '@angular/forms';
import { WrValidators } from 'ngwr/validators';

const cvc  = new FormControl('', [WrValidators.cvc()]);   // 3 digits
const amex = new FormControl('', [WrValidators.cvc(4)]);  // 4 digits
```

## Why ngwr provides this

Pairs with `cardNumber` — length-aware (3 digits, or 4 for Amex) instead of a brittle `pattern`.

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `signature` | Factory — call with the expected length. | `(length?: number) => ValidatorFn` | `—` |
| `length` | Exact digit count. 3 for Visa/MC/Discover, 4 for Amex. | `number` | `3` |
| `error key` | On failure: `{ cvc: { length } }` — the digit count it wanted, so one message can serve both card families. Empty value passes. | `{ cvc: { length: number } }` | `—` |

## See also

- [wr-input](https://ngwr.dev/reference/components/input) — Host control for the 3-4 digit code.
- [cardNumber](https://ngwr.dev/reference/validators/card-number) — Sibling rule for the card number itself.
