**Last updated**: 30 October 2025 | [**Change log**](/access/products/checkout/ios/changelog/)

# CVC validation

Validate your customer's CVC before processing it.

Warning
The validation does not check if your customer's CVC are correct. The validation only checks the format of the entered CVC.

## Get started

* you have added the `AccessCheckoutSDK` to your project as a Cocoapods dependency
* you have added an `import AccessCheckoutSDK` at the top of your swift file


The four basic components for this integration are as follows:

* Your AccessCheckoutUITextField for the CVC.
* An `AccessCheckoutCvcOnlyValidationDelegate` is designed to receive events pertaining to validation.
* An instance of `CvcOnlyValidationConfig` contains all the information required for the initialization of the validation flow, including references to the view component to enable validation for.
* An `AccessCheckoutValidationInitialiser` is responsible for initializing the validation flow.


Full sample integration
You can see an example of the CVC validation integration [here](https://github.com/Worldpay/access-checkout-ios/tree/master/AccessCheckoutDemo).

## Create and reference the UI components

To display your checkout form, you must create your layout first using your storyboard.

Here's an example of how you would reference your UI components using unique identifiers.


```swift
import AccessCheckoutSDK

class ViewController: UIViewController {

  @IBOutlet weak var cvcAccessCheckoutView: AccessCheckoutUITextField!
  ...
```

## Implement the `AccessCheckoutCvcOnlyValidationDelegate` protocol

This ensures you are notified of validation events.


```swift
extension ViewController: AccessCheckoutCvcOnlyValidationDelegate {

  // This event handler is notified when the CVC becomes valid or invalid
    func cvcValidChanged(isValid: Bool) {
      // You might want to change the text color
        cvcAccessCheckoutView.textColor = isValid ? nil : UIColor.red
        
        if !valid {
            // You might want to disable a submit button which would normally be clicked on when all fields are valid
            submitButton.isEnabled = false
        }
    }
    
    // This is complimentary to cvcValidChanged() and is notified only when the CVC is valid
    func validationSuccess() {
        // You might want to enable a submit button
        submitButton.isEnabled = true
   }
}
```

Here's an example.

## Instantiate a `CvcOnlyValidationConfig` and initialize the validation

We recommend that you do this in the `viewDidLoad()` handler of your UIViewController.


```swift
override func viewDidLoad() {
    ...
    let validationConfig = try! CvcOnlyValidationConfig.builder()
                                    .cvc(cvcAccessCheckoutView)
                                    .validationDelegate(self)
                                    .build()
    AccessCheckoutValidationInitialiser().initialise(validationConfig)
}
```

### Create CVC session

Once validation is in place you can request `sessions` to implement your payment flow.

br
**Next steps**

[Create a CVC session](/access/products/checkout/ios/v3/card-and-cvc#create-a-session-for-cvc-only)