refactor: replace ignored numeric literals with constants
This commit is contained in:
@@ -21,11 +21,14 @@ import {
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
|
||||
import { MAX_INSTRUMENT_QUERY_LENGTH, MIN_INSTRUMENT_QUERY_LENGTH } from '../instrument-query';
|
||||
import { InvestmentResourceMetaDto } from '../investment-resource.dto';
|
||||
import { operationCategories } from '../operations/operations.api';
|
||||
|
||||
const MIN_ACCOUNT_ID_LENGTH = 1;
|
||||
const MIN_SYNC_PAGE_SIZE = 1;
|
||||
|
||||
const maxAccountIdLength = 256;
|
||||
const maxQueryLength = 80;
|
||||
const maxPageSize = 1000;
|
||||
|
||||
export const investmentScreens = [
|
||||
@@ -51,7 +54,7 @@ export class InvestmentScreenDto {
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MinLength(MIN_ACCOUNT_ID_LENGTH)
|
||||
@MaxLength(maxAccountIdLength)
|
||||
accountId?: string;
|
||||
|
||||
@@ -83,8 +86,8 @@ export class InvestmentScreenDto {
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MinLength(2)
|
||||
@MaxLength(maxQueryLength)
|
||||
@MinLength(MIN_INSTRUMENT_QUERY_LENGTH)
|
||||
@MaxLength(MAX_INSTRUMENT_QUERY_LENGTH)
|
||||
query?: string;
|
||||
|
||||
@ApiPropertyOptional({ enum: ['month', 'halfYear', 'year', 'all'] })
|
||||
@@ -104,10 +107,10 @@ export class InvestmentScreenDto {
|
||||
@IsIn(operationCategories, { each: true })
|
||||
categories?: (typeof operationCategories)[number][];
|
||||
|
||||
@ApiPropertyOptional({ minimum: 1, maximum: maxPageSize })
|
||||
@ApiPropertyOptional({ minimum: MIN_SYNC_PAGE_SIZE, maximum: maxPageSize })
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Min(MIN_SYNC_PAGE_SIZE)
|
||||
@Max(maxPageSize)
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user