# isArrayLength

```typescript
isArrayLength({ min, max })
```

Verifies if provided `Verificable` represents an array with `length` (number of items) is within specified range. Both `min` and `max` arguments are optional - not providing any of them means value on that 'end' will not be checked.

### Arguments:

* `min` - optional, of type `number`&#x20;
* `max` - optional, of type `number`&#x20;

### Possible errors:

#### If provided `Verificable` is not an array:

```typescript
{
    type: "isArray",
    path: [/* ... */]
}
```

#### If provided `Verificable` is an array with number of items outside the range:

```typescript
{
    type: "isArrayLength",
    path: [/* ... */],
    min: /* provided min value */,
    max: /* provided max value */,
}
```

### Examples:

Each of examples uses this import statement:

```typescript
const { asVerificable, isValid, isArrayLength, getErrors } = require("verifica");
```

#### Non-array values (like string in this example) are not a valid array, and will fail with an `isArray` error:

```typescript
const verificable = asVerificable("something");
isValid(verificable, isArrayLength({ min: 2, max: 4 })); // false
getErrors(verificable, isArrayLength({ min: 2, max: 4 }));
// [ { type: "isArray", path: [] }]
```

#### Array with number of items outside of requested range will fail with `isArrayLength` error:

```typescript
const verificable = asVerificable(["item"]);
isValid(verificable, isArrayLength({ min: 2, max: 4 })); // false
getErrors(verificable, isArrayLength({ min: 2, max: 4 }));
// [ { type: "isArrayLength", path: [], min: 2, max: 4 }]
```

#### Not providing `min`, `max` or both constrains will mean no requirement on those missing 'ends' of the range:

```typescript
const verificable = asVerificable(["item"]);
isValid(verificable, isArrayLength({ max: 4 })); // true
```
