Skip to content

Commit fd3ef0c

Browse files
Merge pull request #1391 from Keimeno/chore/joi-references
docs(pipes,configuration): replaced hapi/joi package and repo references with joi
2 parents 4f7e4fa + c1dd4ef commit fd3ef0c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

content/pipes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ This is, of course, exactly the use case for which pipes are designed. So let's
229229

230230
There are several approaches available for doing object validation in a clean, [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) way. One common approach is to use **schema-based** validation. Let's go ahead and try that approach.
231231

232-
The [Joi](https://github.com/hapijs/joi) library allows you to create schemas in a straightforward way, with a readable API. Let's build a validation pipe that makes use of Joi-based schemas.
232+
The [Joi](https://github.com/sideway/joi) library allows you to create schemas in a straightforward way, with a readable API. Let's build a validation pipe that makes use of Joi-based schemas.
233233

234234
Start by installing the required package:
235235

236236
```bash
237-
$ npm install --save @hapi/joi
238-
$ npm install --save-dev @types/hapi__joi
237+
$ npm install --save joi
238+
$ npm install --save-dev @types/joi
239239
```
240240

241241
In the code sample below, we create a simple class that takes a schema as a `constructor` argument. We then apply the `schema.validate()` method, which validates our incoming argument against the provided schema.
@@ -247,7 +247,7 @@ In the next section, you'll see how we supply the appropriate schema for a given
247247
```typescript
248248
@@filename()
249249
import { PipeTransform, Injectable, ArgumentMetadata, BadRequestException } from '@nestjs/common';
250-
import { ObjectSchema } from '@hapi/joi';
250+
import { ObjectSchema } from 'joi';
251251

252252
@Injectable()
253253
export class JoiValidationPipe implements PipeTransform {

content/techniques/configuration.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,23 +311,23 @@ export class DatabaseModule {}
311311

312312
It is standard practice to throw an exception during application startup if required environment variables haven't been provided or if they don't meet certain validation rules. The `@nestjs/config` package enables two different ways to do this:
313313

314-
- [Joi](https://github.com/hapijs/joi) built-in validator. With Joi, you define an object schema and validate JavaScript objects against it.
314+
- [Joi](https://github.com/sideway/joi) built-in validator. With Joi, you define an object schema and validate JavaScript objects against it.
315315
- A custom `validate()` function which takes environment variables as an input.
316316

317317
To use Joi, we must install Joi package (and its types, for **TypeScript** users):
318318

319319
```bash
320-
$ npm install --save @hapi/joi
321-
$ npm install --save-dev @types/hapi__joi
320+
$ npm install --save joi
321+
$ npm install --save-dev @types/joi
322322
```
323323

324-
> warning **Notice** The latest version of `@hapi/joi` requires you to be running Node v12 or later. For older versions of node, please install `v16.1.8`. This is mainly after the release of `v17.0.2` which causes errors during build time. For more information, please refer to [their documentation](https://hapi.dev/family/joi/?v=17.0.2#install) & this [github issue](https://github.com/hapijs/joi/issues/2266#issuecomment-571667769).
324+
> warning **Notice** The latest version of `joi` requires you to be running Node v12 or later. For older versions of node, please install `v16.1.8`. This is mainly after the release of `v17.0.2` which causes errors during build time. For more information, please refer to [their documentation](https://hapi.dev/family/joi/?v=17.0.2#install) & this [github issue](https://github.com/hapijs/joi/issues/2266#issuecomment-571667769).
325325
326326
Now we can define a Joi validation schema and pass it via the `validationSchema` property of the `forRoot()` method's options object, as shown below:
327327

328328
```typescript
329329
@@filename(app.module)
330-
import * as Joi from '@hapi/joi';
330+
import * as Joi from 'joi';
331331

332332
@Module({
333333
imports: [
@@ -350,7 +350,7 @@ By default, unknown environment variables (environment variables whose keys are
350350

351351
```typescript
352352
@@filename(app.module)
353-
import * as Joi from '@hapi/joi';
353+
import * as Joi from 'joi';
354354

355355
@Module({
356356
imports: [

0 commit comments

Comments
 (0)