# CURP Validation

The CURP Validation module validates a person's CURP (Clave Única de Registro de Población), a personal identification number issued in Mexico, against Mexico's RENAPO registry. It accepts a CURP extracted via OCR, entered manually, or generated from personal data when the user doesn't know it.

For an overview of this module and how it works, see [CURP Validation](https://developer.incode.com/docs/curp-validation).

How you use this module depends on your integration pattern. When the app defines the steps in code, you add the module to an `IncdOnboardingFlowConfiguration` as shown below; when the flow is defined in Dashboard, you reference it by ID and let the back end drive the steps. See [Integration Approaches](https://developer.incode.com/docs/ios-flow-configuration).

**Availability:** All variants; Mexico only.

## Add CURP Validation

Add the module to an `IncdOnboardingFlowConfiguration` with `addCURPValidation(validationEnabled:)`.

```swift
flowConfig.addCURPValidation(validationEnabled: true)
```

## Configuration Options

Configure the module with `addCURPValidation()`.

| Option              | Type    | Description                                                                |
| ------------------- | ------- | -------------------------------------------------------------------------- |
| `validationEnabled` | `Bool?` | Controls whether the entered CURP is validated against the RENAPO service. |

## Result

CURP Validation delivers a `CURPValidationResult` to the `onCURPValidationCompleted(_:)` callback on the `IncdOnboardingDelegate`:

```swift
func onCURPValidationCompleted(_ result: CURPValidationResult)
```

`CURPValidationResult` (conforms to `UserInfoResult`) fields:

- `curp: String?`: The CURP string; `nil` when unavailable.
- `valid: Bool?`: `true` when the CURP was validated successfully; `false` on failed validation; `nil` when validation was skipped or disabled.
- `data: [String: Any]?`: Additional CURP validation data as key/value pairs. May be empty or `nil`.
- `error: IncdError?`: The error that occurred while producing this result, if any; otherwise, `nil`.

Errors for this module surface directly through the `error` field on `CURPValidationResult` rather than a separate exception type.
