Skip to content

Commit

Permalink
Add more validation on admin users filters
Browse files Browse the repository at this point in the history
  • Loading branch information
hkdobrev committed Jun 30, 2021
1 parent f8aabd6 commit abf2b18
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/users/api/users-filters.dto.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
import { Type } from 'class-transformer';
import { IsInt, IsOptional } from 'class-validator';
import {
IsIn,
IsInt,
IsOptional,
IsString,
Length,
Min,
} from 'class-validator';
import { Role } from 'src/casl/role.enum';
import { IsOrganizationExists } from 'src/users/api/organization-exists.constraint';
import { PageDTO } from 'src/utils/page.dto';

export class UsersFilters extends PageDTO {
@IsOptional()
@IsString()
@Length(1, 255)
firstName: string;

@IsOptional()
@IsString()
@Length(1, 255)
lastName: string;

@IsOptional()
@IsString()
@Length(1, 255)
email: string;

@IsOptional()
@IsInt()
@Type(() => Number)
@Min(1)
@IsOrganizationExists()
organization: number;

@IsOptional()
@IsString()
@IsIn(Object.values(Role))
role: string;
}

0 comments on commit abf2b18

Please sign in to comment.