Skip to content

Commit

Permalink
fix(j-s): String Length Validation (#16924)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and jonnigs committed Nov 26, 2024
1 parent bbb1396 commit 5626c2a
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
IsObject,
IsOptional,
IsString,
MaxLength,
} from 'class-validator'

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
Expand All @@ -31,33 +32,39 @@ export class CreateCaseDto {
readonly indictmentSubtypes?: IndictmentSubtypeMap

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly description?: string

@IsNotEmpty()
@IsArray()
@ArrayMinSize(1)
@MaxLength(255)
@IsString({ each: true })
@ApiProperty({ type: String, isArray: true })
readonly policeCaseNumbers!: string[]

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderName?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderNationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderEmail?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderPhoneNumber?: string
Expand All @@ -68,6 +75,7 @@ export class CreateCaseDto {
readonly requestSharedWithDefender?: RequestSharedWithDefender

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly leadInvestigator?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
IsOptional,
IsString,
IsUUID,
MaxLength,
ValidateNested,
} from 'class-validator'

Expand Down Expand Up @@ -43,6 +44,7 @@ class UpdateDateLog {
readonly date?: Date

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly location?: string
Expand All @@ -60,33 +62,39 @@ export class UpdateCaseDto {
readonly indictmentSubtypes?: IndictmentSubtypeMap

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly description?: string

@IsOptional()
@IsArray()
@ArrayMinSize(1)
@MaxLength(255)
@IsString({ each: true })
@ApiPropertyOptional({ type: String, isArray: true })
readonly policeCaseNumbers?: string[]

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderName?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderNationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderEmail?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderPhoneNumber?: string
Expand All @@ -107,6 +115,7 @@ export class UpdateCaseDto {
readonly courtId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly leadInvestigator?: string
Expand All @@ -124,6 +133,7 @@ export class UpdateCaseDto {
readonly requestedCourtDate?: Date

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly translator?: string
Expand Down Expand Up @@ -207,6 +217,7 @@ export class UpdateCaseDto {
readonly sharedWithProsecutorsOfficeId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly courtCaseNumber?: string
Expand All @@ -229,6 +240,7 @@ export class UpdateCaseDto {
readonly courtDate?: UpdateDateLog

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly courtLocation?: string
Expand Down Expand Up @@ -407,6 +419,7 @@ export class UpdateCaseDto {
readonly defendantStatementDate?: Date

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly appealCaseNumber?: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { IsBoolean, IsEnum, IsOptional, IsString } from 'class-validator'
import {
IsBoolean,
IsEnum,
IsOptional,
IsString,
MaxLength,
} from 'class-validator'

import { ApiPropertyOptional } from '@nestjs/swagger'

Expand All @@ -11,11 +17,13 @@ export class CreateDefendantDto {
readonly noNationalId?: boolean

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly nationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly name?: string
Expand All @@ -26,31 +34,37 @@ export class CreateDefendantDto {
readonly gender?: Gender

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly address?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly citizenship?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderName?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderNationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderEmail?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderPhoneNumber?: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsBoolean, IsOptional, IsString } from 'class-validator'
import { IsBoolean, IsOptional, IsString, MaxLength } from 'class-validator'

import { ApiPropertyOptional } from '@nestjs/swagger'

Expand All @@ -9,11 +9,13 @@ export class UpdateCivilClaimantDto {
readonly noNationalId?: boolean

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly name?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly nationalId?: string
Expand All @@ -29,21 +31,25 @@ export class UpdateCivilClaimantDto {
readonly spokespersonIsLawyer?: boolean

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly spokespersonNationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly spokespersonName?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly spokespersonEmail?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly spokespersonPhoneNumber?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
IsEnum,
IsOptional,
IsString,
MaxLength,
} from 'class-validator'

import { ApiPropertyOptional } from '@nestjs/swagger'
Expand All @@ -24,11 +25,13 @@ export class UpdateDefendantDto {
readonly noNationalId?: boolean

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly nationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly name?: string
Expand All @@ -39,31 +42,37 @@ export class UpdateDefendantDto {
readonly gender?: Gender

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly address?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly citizenship?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderName?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderNationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderEmail?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly defenderPhoneNumber?: string
Expand Down Expand Up @@ -106,11 +115,13 @@ export class UpdateDefendantDto {
readonly requestedDefenderChoice?: DefenderChoice

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly requestedDefenderNationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly requestedDefenderName?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
IsNumber,
IsOptional,
IsString,
MaxLength,
} from 'class-validator'

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
Expand All @@ -14,6 +15,7 @@ import { CaseFileCategory } from '@island.is/judicial-system/types'

export class CreateFileDto {
@IsNotEmpty()
@MaxLength(255)
@IsString()
@ApiProperty({ type: String })
readonly type!: string
Expand All @@ -24,6 +26,7 @@ export class CreateFileDto {
readonly category?: CaseFileCategory

@IsNotEmpty()
@MaxLength(255)
@IsString()
@ApiProperty({ type: String })
readonly key!: string
Expand All @@ -34,6 +37,7 @@ export class CreateFileDto {
readonly size!: number

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly policeCaseNumber?: string
Expand All @@ -55,11 +59,13 @@ export class CreateFileDto {
readonly displayDate?: Date

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly policeFileId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@ApiPropertyOptional({ type: String })
readonly userGeneratedFilename?: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { IsNotEmpty, IsString } from 'class-validator'
import { IsNotEmpty, IsString, MaxLength } from 'class-validator'

import { ApiProperty } from '@nestjs/swagger'

export class CreatePresignedPostDto {
@IsNotEmpty()
@MaxLength(255)
@IsString()
@ApiProperty({ type: String })
readonly fileName!: string

@IsNotEmpty()
@MaxLength(255)
@IsString()
@ApiProperty({ type: String })
readonly type!: string
Expand Down
Loading

0 comments on commit 5626c2a

Please sign in to comment.