class-validator#isMongoId TypeScript Examples

The following examples show how to use class-validator#isMongoId. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: update-doubtAnswer.dto.ts    From edu-server with MIT License 6 votes vote down vote up
/**
   * The name of the person who answered the doubt
   * @example '60ccf3037025096f45cb87bf'
   */
  @IsNotEmpty()
  @IsMongoId()
  @IsNotEmpty()
  @ApiProperty({ type: Schema.Types.ObjectId })
  answered_by: Schema.Types.ObjectId;
Example #2
Source File: update-doubt.dto.ts    From edu-server with MIT License 6 votes vote down vote up
/**
   * The name of the person who asked the doubt
   * @example '60ccf3037025096f45cb87bf'
   */
  @IsNotEmpty()
  @IsMongoId()
  @IsNotEmpty()
  @ApiProperty({ type: Schema.Types.ObjectId })
  asked_by: Schema.Types.ObjectId;
Example #3
Source File: create-doubtAnswer.dto.ts    From edu-server with MIT License 6 votes vote down vote up
/**
   * The id of the person who answered the doubt
   * @example '60ccf3037025096f45cb87bf'
   */
  @IsNotEmpty()
  @IsMongoId()
  @IsNotEmpty()
  @ApiProperty({ type: Schema.Types.ObjectId })
  answered_by: Schema.Types.ObjectId;
Example #4
Source File: create-doubt.dto.ts    From edu-server with MIT License 6 votes vote down vote up
/**
   * The id of the person who asked the doubt
   * @example '60ccf3037025096f45cb87bf'
   */
  @IsNotEmpty()
  @IsMongoId()
  @IsNotEmpty()
  @ApiProperty({ type: Schema.Types.ObjectId })
  asked_by: Schema.Types.ObjectId;
Example #5
Source File: create-review.dto.ts    From edu-server with MIT License 5 votes vote down vote up
/**
   * Reviewer's MongoId
   * @example "60dcbd2609c34c1e48d2d0ae"
   */
  @IsNotEmpty()
  @IsMongoId()
  reviewerId: string;
Example #6
Source File: tracks.controller.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@Post(':trackId/reassign_mentee')
  @HttpCode(HttpStatus.OK)
  @ApiResponse({ status: HttpStatus.OK })
  @UseGuards(JwtAuthGuard, RolesGuard)
  @Roles(UserRole.ADMIN)
  @ApiBearerAuth()
  @ApiResponse({ status: HttpStatus.BAD_REQUEST, type: ApiException })
  async reassignMentee(
    @Param('trackId') trackId: string,
    @Body() input: ReassignMenteeInput,
    @Req() req: Request
  ): Promise<void> {
    if (!isMongoId(trackId)) throw new BadRequestException('Invalid track ID');
    const mentee = await this.userService.findOneAsync({
      _id: input.menteeId,
      role: UserRole.MENTEE
    });
    if (!mentee)
      throw new NotFoundException(`Mentee with Id ${input.menteeId} not found`);
    const toMentor = await this.userService.findOneAsync({
      _id: input.toMentorId,
      role: UserRole.MENTOR
    });
    if (!toMentor)
      throw new NotFoundException(
        `Mentor with Id ${input.toMentorId} not found`
      );
    if (input.fromMentorId) {
      const fromMentor = await this.userService.findOneAsync({
        _id: input.fromMentorId,
        role: UserRole.MENTOR
      });
      if (!fromMentor)
        throw new NotFoundException(
          `Mentor with Id ${input.fromMentorId} not found`
        );
    }

    const track = await this.trackService.findByIdAsync(trackId);
    if (!track)
      throw new NotFoundException(`Track with Id ${trackId} not found`);

    await this.mentorService.reassignMentee({
      trackId,
      menteeId: input.menteeId,
      fromMentorId: input.fromMentorId,
      toMentorId: input.toMentorId,
      adminId: req.user['id']
    });
  }
Example #7
Source File: User.ts    From tezos-academy with MIT License 5 votes vote down vote up
@IsMongoId()
  readonly _id!: ObjectId
Example #8
Source File: PublicUser.ts    From tezos-academy with MIT License 5 votes vote down vote up
@IsMongoId()
  readonly _id!: ObjectId
Example #9
Source File: Quota.ts    From tezos-academy with MIT License 5 votes vote down vote up
@Property({ required: true, ref: 'User' })
  @IsMongoId()
  userId!: ObjectId
Example #10
Source File: Quota.ts    From tezos-academy with MIT License 5 votes vote down vote up
@IsMongoId()
  readonly _id!: ObjectId
Example #11
Source File: Captcha.ts    From tezos-academy with MIT License 5 votes vote down vote up
@Property({ required: true, ref: 'User' })
  @IsMongoId()
  userId!: ObjectId
Example #12
Source File: Captcha.ts    From tezos-academy with MIT License 5 votes vote down vote up
@IsMongoId()
  readonly _id!: ObjectId
Example #13
Source File: create-enrolled.dto.ts    From edu-server with MIT License 5 votes vote down vote up
@IsNotEmpty()
  @IsMongoId()
  @ApiProperty({ type: Schema.Types.ObjectId })
  courseId: Schema.Types.ObjectId;
Example #14
Source File: create-enrolled.dto.ts    From edu-server with MIT License 5 votes vote down vote up
@IsNotEmpty()
  @IsMongoId()
  @ApiProperty({ type: Schema.Types.ObjectId })
  studentId: Schema.Types.ObjectId;
Example #15
Source File: mentor-mentee.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  track: string;
Example #16
Source File: create-track.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  toMentorId: string;
Example #17
Source File: create-track.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  @IsOptional()
  fromMentorId?: string;
Example #18
Source File: create-track.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  menteeId: string;
Example #19
Source File: create-track.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  mentorId: string;
Example #20
Source File: task.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  // @IsOptional()
  course: string;
Example #21
Source File: task.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  stage: string;
Example #22
Source File: task.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  track: string;
Example #23
Source File: create-stage.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  track: string;
Example #24
Source File: base.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId({ each: true })
  @Expose()
  @ApiProperty({ isArray: true, type: String })
  ids: string[];
Example #25
Source File: base.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  readonly id: string;
Example #26
Source File: mentor-mentee.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  mentee: string;
Example #27
Source File: mentor-mentee.dto.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
@IsMongoId()
  @Expose()
  mentor: string;