> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# validate

Perform a validation process on the provided `additional payment method data` for a given `vaultedPaymentMethodId`.

```swift SWIFT theme={"dark"}
func validate(
    vaultedPaymentMethodId: String,
    vaultedPaymentMethodAdditionalData: PrimerVaultedPaymentMethodAdditionalData,
    completion: @escaping (_ errors: [Error]?) -> Void
)
```

## Parameters

**Parameters**

**vaultedPaymentMethodId** `String` *required*

The `id` of a `PrimerHeadlessUniversalCheckout.VaultedPaymentMethod` previously retrieved with [fetchVaultedPaymentMethods](https://primer.io/docs/sdk/ios/v2.x.x/primer-headless-checkout/vault-manager/fetchVaultedPaymentMethods.md).

**vaultedPaymentMethodAdditionalData** `PrimerVaultedPaymentMethodAdditionalData` *required*

**Direct Subclasses**

**PrimerVaultedCardAdditionalData**

**Properties**

**cvv** `String` *required*

CVV value associated with the vaulted card.

## Returns

The `validate` method performs validation operation for the given `vaultedPaymentMethodId` and `vaultedPaymentMethodAdditionalData`.
The completion handler will either return an array of errors, or `nil` if validation is successful.

The errors returned can be cast to `PrimerError` or `PrimerValidationError`.

**Returns**

**completion**

Completion will be called when the validation has been completed and the
result is available.

**errors** `Array\<Error\>`

**Errors**

**invalidVaultedPaymentMethodId** `PrimerError`

An error that will be thrown in case the you provide a vaulted payment method that doesn't exist.

**invalidCvv** `PrimerValidationError`

An error that will be thrown in case the CVV/CVC is not valid.

## Example

```swift SWIFT theme={"dark"}
import UIKit
import PrimerSDK

class MerchantHeadlesVaultManagerViewController: UIViewController {

  var vaultManager = PrimerHeadlessUniversalCheckout.VaultManager()

  override func viewDidLoad() {
    super.viewDidLoad()

    do {
      // Before you configure your vault manager you must have started
      // PrimerHeadlessUniversalCheckout with a client token.
      try self.vaultManager.configure()

    } catch {
      // Handler the error
    }
  }

  func validateCVV(_ cvv: String, forVaultedPaymentMethodWithId id: String) {
    let vaultedCardAdditionalData = PrimerVaultedCardAdditionalData(cvv: cvv)
    // 👇 Call validate
    self.vaultManager.validate(vaultedPaymentMethodId: id, vaultedPaymentMethodAdditionalData: vaultedCardAdditionalData, completion: { errors in
      if let errors = errors {
        // Handle validation errors
      }
    })
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.