> For the complete documentation index, see [llms.txt](https://radoslaw-medryk.gitbook.io/verifica/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://radoslaw-medryk.gitbook.io/verifica/predicates/built-in-predicates/isstringlength.md).

# 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
```


---

# 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://radoslaw-medryk.gitbook.io/verifica/predicates/built-in-predicates/isstringlength.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.
