Skip to content

Commit e107108

Browse files
authored
Port validation configuration to our library (#3646)
1 parent c795f7b commit e107108

File tree

6 files changed

+17
-54
lines changed

6 files changed

+17
-54
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@seedcompany/cache": "^4.0.1",
5757
"@seedcompany/common": "^1.3.0",
5858
"@seedcompany/data-loader": "^3.0.0",
59-
"@seedcompany/nest": "^2.2.5",
59+
"@seedcompany/nest": "^2.2.6",
6060
"@seedcompany/nestjs-email": "^6.0.0",
6161
"@seedcompany/scripture": "^1.0.0",
6262
"argon2": "^0.43.0",

src/components/changeset/dto/changeset.args.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { Injectable, type PipeTransform } from '@nestjs/common';
1+
import { Injectable, type PipeTransform, ValidationPipe } from '@nestjs/common';
22
import { Args, ArgsType } from '@nestjs/graphql';
33
import { type ID, IdField, type ObjectView } from '~/common';
4-
import { ValidationPipe } from '~/core/validation';
54

65
/**
76
* A helper for id & changeset arguments.

src/core/validation/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export * from './validation.exception';
2-
export * from './validation.pipe';
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { Module } from '@nestjs/common';
2-
import { APP_PIPE } from '@nestjs/core';
3-
import { Validator } from 'class-validator';
2+
import { ValidatorModule } from '@seedcompany/nest';
43
import {
54
ValidateIdPipe,
65
ValidIdConstraint,
76
} from '~/common/validators/short-id.validator';
8-
import { ValidationPipe } from './validation.pipe';
7+
import { ValidationException } from './validation.exception';
98

109
@Module({
11-
providers: [
12-
Validator,
13-
ValidationPipe,
14-
{ provide: APP_PIPE, useExisting: ValidationPipe },
15-
ValidIdConstraint,
16-
ValidateIdPipe,
10+
imports: [
11+
ValidatorModule.register({
12+
transform: true,
13+
skipMissingProperties: true,
14+
exceptionFactory: (es) => new ValidationException(es),
15+
}),
1716
],
18-
exports: [ValidationPipe, ValidateIdPipe],
17+
providers: [ValidIdConstraint, ValidateIdPipe],
18+
exports: [ValidatorModule, ValidateIdPipe],
1919
})
2020
export class ValidationModule {}

src/core/validation/validation.pipe.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3839,9 +3839,9 @@ __metadata:
38393839
languageName: node
38403840
linkType: hard
38413841

3842-
"@seedcompany/nest@npm:^2.2.5":
3843-
version: 2.2.5
3844-
resolution: "@seedcompany/nest@npm:2.2.5"
3842+
"@seedcompany/nest@npm:^2.2.6":
3843+
version: 2.2.6
3844+
resolution: "@seedcompany/nest@npm:2.2.6"
38453845
dependencies:
38463846
"@graphql-yoga/redis-event-target": "npm:^3.0.3"
38473847
"@graphql-yoga/typed-event-target": "npm:^3.0.2"
@@ -3862,7 +3862,7 @@ __metadata:
38623862
class-transformer: ^0.5.1
38633863
class-validator: ^0.14.0
38643864
reflect-metadata: ^0.1.12 || ^0.2.0
3865-
checksum: 10c0/46f576c3d9e22361b49db7b18f19fca3925f219515534382eb53e0253bbb435efabfd967a494374d941a1affc210ca6015b55331881bd51b6ff701a755bbfb9b
3865+
checksum: 10c0/1ec05505b77dbd198679c8d559343b840b477343f7d3b462459101984bc23a8295b5cd25eb50993b2dc685b835a696b938b4a02d3936b4bdf50369e982bac629
38663866
languageName: node
38673867
linkType: hard
38683868

@@ -6708,7 +6708,7 @@ __metadata:
67086708
"@seedcompany/common": "npm:^1.3.0"
67096709
"@seedcompany/data-loader": "npm:^3.0.0"
67106710
"@seedcompany/eslint-plugin": "npm:^3.4.1"
6711-
"@seedcompany/nest": "npm:^2.2.5"
6711+
"@seedcompany/nest": "npm:^2.2.6"
67126712
"@seedcompany/nestjs-email": "npm:^6.0.0"
67136713
"@seedcompany/scripture": "npm:^1.0.0"
67146714
"@tsconfig/strictest": "npm:^2.0.2"

0 commit comments

Comments
 (0)