---
description: The module provides a set of functions to generate random values.
---

# Random

### Imports

{% tabs %}
{% tab title="Service" %}
```typescript
import { RandomService } from 'niro-health';
```
{% endtab %}

{% tab title="Module" %}
```typescript
import { RandomModule } from 'niro-health';
```
{% endtab %}

{% tab title="Interface" %}
```typescript
import type { IRandomService } from 'niro-health';
```
{% endtab %}
{% endtabs %}

### Method of Use

To use this module, you need to inject it into the desired service.

{% code overflow="wrap" %}
```typescript
import { Module } from '@nestjs/common';
import {
  RandomService,
  StringExService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IRandomService',
      useClass: RandomService,
    },
    {
      provide: 'IStringExService',
      useClass: StringExService,
    },
  ],
})
export class AppModule {}
```
{% endcode %}

Injecting the module into our service.

```typescript
import { Inject, Injectable } from '@nestjs/common';
import type { IRandomService } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IRandomService')
    private readonly randomService: IRandomService,
  ) {}

  public integer() {
    return this.randomService.int(100);
  }
}
```

### With dependencies

You will need to inject the following interfaces.

<table><thead><tr><th width="308">Interface</th><th>Service</th></tr></thead><tbody><tr><td><code>IStringExService</code></td><td><a href="stringex">Link to Service documentation</a></td></tr></tbody></table>

### Methods

<table><thead><tr><th width="301.3333333333333">Method</th><th width="129" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>int</code></td><td align="center"><code>public</code></td><td><code>Returns a random integer between min and max.</code></td></tr><tr><td><code>hash</code></td><td align="center"><code>public</code></td><td><code>Returns a random string format of HASH.</code></td></tr><tr><td><code>uuid</code></td><td align="center"><code>public</code></td><td><code>Returns a random string format of UUID.</code></td></tr><tr><td><code>password</code></td><td align="center"><code>public</code></td><td><code>Returns a random password.</code></td></tr><tr><td><code>string</code></td><td align="center"><code>public</code></td><td><code>Returns a random string of characters.</code></td></tr></tbody></table>
