refactor: replace ignored numeric literals with constants

This commit is contained in:
2026-09-28 16:37:01 +03:00
committed by ksv741
parent a970eaaf7a
commit b78c215ff1
60 changed files with 510 additions and 283 deletions
@@ -2,6 +2,9 @@ import { BadRequestException } from '@nestjs/common';
import type { InvestmentScreenDto } from './tbank-sync.dto';
import { ISO_DATE_LENGTH, ISO_DATE_START } from '../../../common/time';
import { MIN_INSTRUMENT_QUERY_LENGTH } from '../instrument-query';
// Reject fields from other screens before reserving any source work.
export function normalizeScreen(
input: InvestmentScreenDto,
@@ -61,7 +64,7 @@ export function normalizeScreen(
}
if (
['bonds', 'stocks'].includes(input.screen) &&
(!query || query.length < 2)
(!query || query.length < MIN_INSTRUMENT_QUERY_LENGTH)
) {
fail();
}
@@ -81,7 +84,7 @@ export function normalizeScreen(
if (
input.screen === 'events' &&
input.to &&
(input.from ?? new Date().toISOString().slice(0, 10)) > input.to
(input.from ?? new Date().toISOString().slice(ISO_DATE_START, ISO_DATE_LENGTH)) > input.to
) {
fail();
}