Browse Source

Add MCP tool to import activities

pull/7766/head
Thomas Kaul 2 months ago
parent
commit
827aa2de63
  1. 10
      libs/common/src/lib/helper.spec.ts
  2. 4
      libs/common/src/lib/helper.ts
  3. 2
      libs/common/src/lib/validator-constraints/is-after-1970.ts

10
libs/common/src/lib/helper.spec.ts

@ -436,6 +436,16 @@ describe('Helper', () => {
expect(isValidDateAfter1970('0000-01-01')).toEqual(false);
});
it('Date object', () => {
expect(
isValidDateAfter1970(new Date('2024-01-01T12:00:00.000Z'))
).toEqual(true);
});
it('Date object of 1970', () => {
expect(isValidDateAfter1970(new Date(0))).toEqual(false);
});
it('Date of 1970', () => {
expect(isValidDateAfter1970('1970-01-01T00:00:00.000Z')).toEqual(false);
});

4
libs/common/src/lib/helper.ts

@ -685,8 +685,8 @@ export function isValidCustomAssetProfileSymbol(aSymbol: string) {
return hasGhostfolioPrefix(aSymbol) || isUUID(aSymbol);
}
export function isValidDateAfter1970(aDate: string) {
const date = parseISO(aDate, { in: utc });
export function isValidDateAfter1970(aDate: Date | string) {
const date = isString(aDate) ? parseISO(aDate, { in: utc }) : aDate;
return isValid(date) && isAfter(date, new Date(0));
}

2
libs/common/src/lib/validator-constraints/is-after-1970.ts

@ -12,7 +12,7 @@ export class IsAfter1970Constraint implements ValidatorConstraintInterface {
return `date must be after ${format(new Date(0), 'yyyy')}`;
}
public validate(aDate: string) {
public validate(aDate: Date | string) {
return isValidDateAfter1970(aDate);
}
}

Loading…
Cancel
Save