Skip to content

Commit ee6cae0

Browse files
chore: minor improvements
1 parent cd84397 commit ee6cae0

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ export * from './errors';
44
export * from './factories';
55
export * from './interfaces';
66
export * from './mongoose.module';
7-
export * from './utils';
87
export * from './pipes';
8+
export * from './utils';

lib/pipes/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './is-object-id.pipe'
2-
export * from './parse-object-id.pipe'
1+
export * from './is-object-id.pipe';
2+
export * from './parse-object-id.pipe';

lib/pipes/is-object-id.pipe.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { ArgumentMetadata, BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
1+
import { BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
22
import { Types } from 'mongoose';
33

44
@Injectable()
55
export class IsObjectIdPipe implements PipeTransform {
6-
transform(value: string, metadata: ArgumentMetadata): string {
6+
transform(value: string): string {
77
const isValidObjectId = Types.ObjectId.isValid(value);
88

99
if (!isValidObjectId) {
10-
throw new BadRequestException("Invalid ObjectId");
10+
throw new BadRequestException(
11+
`Invalid ObjectId: '${value}' is not a valid MongoDB ObjectId`,
12+
);
1113
}
1214

1315
return value;

lib/pipes/parse-object-id.pipe.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { ArgumentMetadata, BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
1+
import { BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
22
import { Types } from 'mongoose';
33

44
@Injectable()
55
export class ParseObjectIdPipe implements PipeTransform {
6-
transform(value: string, metadata: ArgumentMetadata): Types.ObjectId {
6+
transform(value: string): Types.ObjectId {
77
const isValidObjectId = Types.ObjectId.isValid(value);
88

99
if (!isValidObjectId) {
10-
throw new BadRequestException("Invalid ObjectId");
10+
throw new BadRequestException(
11+
`Invalid ObjectId: '${value}' is not a valid MongoDB ObjectId`,
12+
);
1113
}
1214

1315
return new Types.ObjectId(value);

0 commit comments

Comments
 (0)