# isStringLength

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

Verifies if provided `Verificable` represents a string with `length` 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 a string:

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

#### If provided `Verificable` is a string with length being outside of the range:

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

### Examples:

Each of examples uses this import statement:

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

#### Non-string values will fail with an `isString` error:

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

#### String values with length outside of requested range will fail with `isStringLength` error:

```typescript
const verificable = asVerificable("Quite a long string");
isValid(verificable, isStringLength({ min: 2, max: 4 })); // false
getErrors(verificable, isStringLength({ min: 2, max: 4 }));
// [ { type: "isStringLength", path: [], min: 2, max: 4 }]
```

#### String values with length inside of requested range will match:

```typescript
const verificable = asVerificable("abc");
isValid(verificable, isStringLength({ min: 2, max: 4 })); // true
```

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

```typescript
const verificable = asVerificable("Quite a long string");
isValid(verificable, isStringLength({ min: 2 })); // true
```
