# static isRange()

## `Range.isRange()`

The static `isRange()` method checks whether the [`value`](#value-any) is an instance of [`Range`](https://docs.angular-package.dev/range-1/range) of any or the given [**minimum**](#min-min), [**maximum**](#max-max) range and [step](#step-step).

{% code title="range.class.ts" %}

```typescript
public static isRange<
  Min extends number,
  Max extends number,
  Step extends number
>(
  value: any,
  min?: Min,
  max?: Max,
  step?: Step
): value is Range<Min, Max, Step> {
  return typeof value === 'object' && value instanceof this
    ? (typeof min === 'number' ? value.min === min : true) &&
        (typeof max === 'number' ? value.max === max : true) &&
        (typeof step === 'number' ? value.step === step : true)
    : false;
}
```

{% endcode %}

### Generic type variables

#### <mark style="color:green;">`Min`</mark>`extends`[<mark style="color:green;">`number`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#number)

A generic type variable constrained by the [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number), by default of the value **captured** from the supplied [`min`](#min-min) indicates the **minimum** range type via the [return type](#return-type).

#### <mark style="color:green;">`Max`</mark>`extends`[<mark style="color:green;">`number`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#number)

A generic type variable constrained by the [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number), by default of the value **captured** from the supplied [`max`](#max-max) indicates the **maximum** range type via the [return type](#return-type).

#### <mark style="color:green;">`Step`</mark>`extends`[<mark style="color:green;">`number`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#number)

A generic type variable constrained by the [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number), by default of the value equal to **`1`**, optionally **captured** from the supplied [`step`](#step-step) indicates the range step type via [return type](#return-type).

### Parameters

#### `value:`[<mark style="color:green;">`any`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#any)

The value of [`any`](https://www.typescriptlang.org/docs/handbook/basic-types.html#any) type to test against the [`Range`](https://docs.angular-package.dev/range-1/range) instance.

#### `min?:`[<mark style="color:green;">`Min`</mark>](#minextendsnumber)

The optional **minimum** range of generic type variable [`Min`](#minextendsnumber) to check whether it's equal to a **minimum** of the given [`value`](#value-any).

#### `max?:`[<mark style="color:green;">`Max`</mark>](#minextendsnumber-1)

The optional **maximum** range of generic type variable [`Max`](#maxextendsnumber) to check whether it's equal to a **maximum** of the given [`value`](#value-any).

#### `step?:`[<mark style="color:green;">`Step`</mark>](#stepextendsnumber-1)

Optional step of generic type variable [`Step`](#stepextendsnumber) to check whether it's equal to the step of the given [`value`](#value-any).

### Return type

#### `value is`[<mark style="color:green;">`Range`</mark>](https://docs.angular-package.dev/range-1/range)`<`[<mark style="color:green;">`Min`</mark>](#minextendsnumber)`,`[<mark style="color:green;">`Max`</mark>](#maxextendsnumber)`,`[<mark style="color:green;">`Step`</mark>](#stepextendsnumber)`>`

The **return type** is a [`boolean`](https://www.typescriptlang.org/docs/handbook/basic-types.html#boolean) resulting from its statement indicating the [`value`](#value-any) is the [`Range`](https://docs.angular-package.dev/range-1/range) object that takes the generic type variable [`Min`](#minextendsnumber), [`Max`](#maxextendsnumber) and [`Step`](#stepextendsnumber).

### Returns

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) indicating whether the provided [`value`](#value-any) is an instance of [`Range`](https://docs.angular-package.dev/range-1/range) of any or the given [minimum](#min-min), [maximum](#max-max) range and [`step`](#step-step).

## Example usage

```typescript
// Example usage.
import { Range } from '@angular-package/range';

// Create new instance.
const range = new Range(4, 27, 1.5);

// Returns true of type value is Range<number, number, number>
Range.isRange(range);

// Returns true of type value is Range<4, number, number>
Range.isRange(range, 4);

// Returns true of type value is Range<4, 27, number>
Range.isRange(range, 4, 27);

// Returns true of type value is Range<4, 27, 1.5>
Range.isRange(range, 4, 27, 1.5);

// Returns false of type value is Range<3, number, number>
Range.isRange(range, 3);

// Returns false of type value is Range<3, 26, number>
Range.isRange(range, 3, 26);

// Returns false of type value is Range<3, 26, 1.0>
Range.isRange(range, 3, 26, 1.0);

// Returns true of type value is Range<number, 27, number>
Range.isRange(range, undefined, 27);

// Returns true of type value is Range<number, number, 1.5>
Range.isRange(range, undefined, undefined, 1.5);
```


---

# 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://docs.angular-package.dev/range-1/range/methods/static-isrange.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.
