> For the complete documentation index, see [llms.txt](https://antonioru.gitbook.io/deep-waters/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://antonioru.gitbook.io/deep-waters/validators/arrayof.md).

# arrayOf

Takes a **validator** and returns a new function that makes sure the received **array** matches the defined validator for each one if its elements.

```javascript
import arrayOf from 'deep-waters/arrayOf';
import isNumber from 'deep-waters/isNumber';
import isString from 'deep-waters/isString';

// array of numbers only
const arrayOfNumbers = arrayOf(isNumber); 

arrayOfNumbers([1, 2, 3, 4]); // → true;
arrayOfNumbers(['s', 't,' 'r', 'i', 'n', 'g']); // → false;

// array of multiple types
const numAndStrings = arrayOf(or(isNumber, isString));

numAndStrings([1, 2, 3, 4, 'can I have a little more?']); // → true;
```

{% hint style="info" %}
**arrayOf** is actually a semantic shortcut to [every](/deep-waters/validators/every.md)
{% endhint %}

#### Related validators

{% content-ref url="/pages/-M6UFKki6F2W4tNMsAag" %}
[every](/deep-waters/validators/every.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M6R\_AciCPylLO5Q93t-" %}
[arrayOfShape](/deep-waters/validators/arrayofshape.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://antonioru.gitbook.io/deep-waters/validators/arrayof.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
