Skip to content

Commit 1314520

Browse files
committed
replaced hapi/joi package and repo references with joi
1 parent 201a55b commit 1314520

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
@@ -238,22 +238,22 @@ export class DatabaseModule {}
238238
239239
#### Schema validation
240240

241-
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 use of the [Joi](https://github.com/hapijs/joi) npm package to support this type of validation. With Joi, you define an object schema and validate JavaScript objects against it.
241+
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 use of the [Joi](https://github.com/sideway/joi) npm package to support this type of validation. With Joi, you define an object schema and validate JavaScript objects against it.
242242

243243
Install Joi (and its types, for **TypeScript** users):
244244

245245
```bash
246-
$ npm install --save @hapi/joi
247-
$ npm install --save-dev @types/hapi__joi
246+
$ npm install --save joi
247+
$ npm install --save-dev @types/joi
248248
```
249249

250-
> 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).
250+
> 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).
251251
252252
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:
253253

254254
```typescript
255255
@@filename(app.module)
256-
import * as Joi from '@hapi/joi';
256+
import * as Joi from 'joi';
257257

258258
@Module({
259259
imports: [
@@ -276,7 +276,7 @@ By default, unknown environment variables (environment variables whose keys are
276276

277277
```typescript
278278
@@filename(app.module)
279-
import * as Joi from '@hapi/joi';
279+
import * as Joi from 'joi';
280280

281281
@Module({
282282
imports: [

0 commit comments

Comments
 (0)