refactor: replace ignored numeric literals with constants
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user