# isNumberInRange

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

Verifies if provided `Verificable` represents a finite number 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 number:

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

#### If provided `Verificable` is not a finite number:

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

#### If provided `Verificable` is a number outside the range:

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

### Examples:

Each of examples uses this import statement:

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

#### Null or undefined is not considered a number:

```typescript
const verificable = asVerificable(null);
isValid(verificable, isNumberInRange({ min: 100, max: 200 })); // false
```

#### String value is not considered a number as well:

```typescript
const verificable = asVerificable("123");
isValid(verificable, isNumberInRange({ min: 100, max: 200 })); // false
```

#### Not finite numbers will not match with `isFiniteNumber` error:

```typescript
const verificable = asVerificable(Infinity);
isValid(verificable, isNumberInRange({ min: 100 })); // false
getErrors(verificable, isNumberInRange({ min: 100 }));
// [{ type: "isFiniteNumber", path: [] }]
```

#### Any finite number outside of requested range will fail with `isNumberInRange` error:

```typescript
const verificable = asVerificable(9999);
isValid(verificable, isNumberInRange({ min: 100, max: 200 })); // false
getErrors(verificable, isNumberInRange({ min: 100, max: 200 }));
// [{ type: "isNumberInRange", min: 100, max: 200, path: [] }]
```

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

```typescript
const verificable = asVerificable(9999);
isValid(verificable, isNumberInRange({ min: 100 })); // true
```


---

# Agent Instructions: 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/isnumberinrange.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.
