Skip to content

Commit

Permalink
Merge pull request #34 from bcgov/feat/update-post-length-limits
Browse files Browse the repository at this point in the history
Update length limits
  • Loading branch information
hannah-macdonald1 authored Nov 21, 2024
2 parents 0e2513c + 1bea05e commit b3dd731
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/common/constants/parameter-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const uniformResponseParamName = 'uniformresponse';
const recordCountHeaderName = 'total-record-count';
const sinceParamName = 'since';

const idRegex = /[0-9\-A-Za-z]+/;
const idMaxLength = 100;
const idRegex = /^[0-9\-A-Za-z]{1,100}$/;
const idName = 'rowId';

const casesAttachmentsFieldName = 'No Intervention';
Expand All @@ -22,6 +23,7 @@ export {
uniformResponseParamName,
recordCountHeaderName,
sinceParamName,
idMaxLength,
idRegex,
idName,
casesAttachmentsFieldName,
Expand Down
4 changes: 4 additions & 0 deletions src/common/constants/upstream-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const pageSizeMax = 100;
const pageSizeDefault = 10;
const startRowNumMin = 0;
const startRowNumDefault = 0;
const visitDetailsMax = 100;
const visitDescriptionMax = 4000;

export {
baseUrlEnvVarName,
Expand All @@ -36,4 +38,6 @@ export {
pageSizeDefault,
startRowNumMin,
startRowNumDefault,
visitDetailsMax,
visitDescriptionMax,
};
3 changes: 2 additions & 1 deletion src/dto/filter-query-params.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { Expose } from 'class-transformer';
import { Exclude, Expose } from 'class-transformer';
import {
IsEnum,
IsInt,
Expand All @@ -21,6 +21,7 @@ import {
} from '../common/constants/upstream-constants';
import { sinceParamName } from '../common/constants/parameter-constants';

@Exclude()
export class FilterQueryParams {
@IsOptional()
@IsISO8601({ strict: true })
Expand Down
8 changes: 7 additions & 1 deletion src/dto/id-path-params.dto.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { ApiProperty } from '@nestjs/swagger';
import { Matches } from 'class-validator';
import { idName, idRegex } from '../common/constants/parameter-constants';
import {
idMaxLength,
idName,
idRegex,
} from '../common/constants/parameter-constants';

export class IdPathParams {
@Matches(idRegex)
@ApiProperty({
example: 'Entity-Id-Here',
description: 'The Entity Id for your selected record type.',
maxLength: idMaxLength,
pattern: idRegex.toString().replaceAll('/', ''),
})
[idName]: string;
}
12 changes: 9 additions & 3 deletions src/dto/post-in-person-visit.dto.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { Expose, Transform } from 'class-transformer';
import { Exclude, Expose, Transform } from 'class-transformer';
import { isPastISO8601Date } from '../helpers/utilities/utilities.service';
import { ApiProperty, ApiSchema } from '@nestjs/swagger';
import { IsEnum, IsNotEmpty } from 'class-validator';
import { IsEnum, IsNotEmpty, MaxLength } from 'class-validator';
import { VisitDetails } from '../common/constants/enumerations';
import {
childVisitEntityIdFieldName,
childVisitIdirFieldName,
childVisitType,
visitDescriptionMax,
visitDetailsMax,
} from '../common/constants/upstream-constants';

@Exclude()
@ApiSchema({ name: 'PostInPersonVisitRequest' })
export class PostInPersonVisitDto {
@Transform(({ value }) => {
Expand All @@ -24,21 +27,24 @@ export class PostInPersonVisitDto {
})
'Date of visit': string;

// TODO: limit string length once given info about limits
@IsNotEmpty()
@MaxLength(visitDescriptionMax)
@Expose()
@ApiProperty({
example: 'Comments here',
description: 'Visit comments',
maxLength: visitDescriptionMax,
})
'Visit Description': string;

@IsEnum(VisitDetails)
@MaxLength(visitDetailsMax)
@Expose()
@ApiProperty({
example: VisitDetails.PrivateVisitInHome,
description: 'The visit type',
enum: VisitDetails,
maxLength: visitDetailsMax,
})
'Visit Details Value': string;
}
Expand Down

0 comments on commit b3dd731

Please sign in to comment.