Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update length limits #34

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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