Title: AbstractDataTransferObject::validateFromArrayData
Published: May 20, 2026

---

# AbstractDataTransferObject::validateFromArrayData( WordPressAiClientCommonarray $data, string[] $requiredKeys )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wordpress-aiclient-common-abstractdatatransferobject/validatefromarraydata/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-common-abstractdatatransferobject/validatefromarraydata/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-common-abstractdatatransferobject/validatefromarraydata/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wordpress-aiclient-common-abstractdatatransferobject/validatefromarraydata/?output_format=md#wp--skip-link--target)

Validates that required keys exist in the array data.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wordpress-aiclient-common-abstractdatatransferobject/validatefromarraydata/?output_format=md#parameters)󠁿

 `$data`<span class="WordPressAiClientCommonarray”>WordPressAiClientCommonarrayrequired

The array data to validate.

`$requiredKeys`string[]required

The keys that must be present.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-common-abstractdatatransferobject/validatefromarraydata/?output_format=md#source)󠁿

    ```php
    protected static function validateFromArrayData(array $data, array $requiredKeys): void
    {
        $missingKeys = [];
        foreach ($requiredKeys as $key) {
            if (!array_key_exists($key, $data)) {
                $missingKeys[] = $key;
            }
        }
        if (!empty($missingKeys)) {
            throw new InvalidArgumentException(sprintf('%s::fromArray() missing required keys: %s', static::class, implode(', ', $missingKeys)));
        }
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/php-ai-client/src/common/abstractdatatransferobject.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/php-ai-client/src/Common/AbstractDataTransferObject.php#L39)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/php-ai-client/src/Common/AbstractDataTransferObject.php#L39-L50)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-common-abstractdatatransferobject/validatefromarraydata/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.1.0](https://developer.wordpress.org/reference/since/0.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwordpress-aiclient-common-abstractdatatransferobject%2Fvalidatefromarraydata%2F)
before being able to contribute a note or feedback.