Change minimum transaction date from 2000 to 1995 (#6440)

This change updates the minimum allowed date for transactions from
2000-01-01 to 1995-01-01, allowing users to enter older transaction
dates without crashes. This addresses the date validation bug that
was causing issues with old dates.

- Updated date validation in schema-helpers.ts
- Updated corresponding tests in schema-helpers.test.ts
This commit is contained in:
Matiss Janis Aboltins
2025-12-19 18:06:04 +00:00
committed by GitHub
parent d437d6e4f3
commit 80bb888bae
3 changed files with 13 additions and 7 deletions

View File

@@ -210,15 +210,15 @@ describe('schema-helpers', () => {
}).toThrow('Cant convert to integer');
});
test('dates before 2000-01-01 are rejected', () => {
test('dates before 1995-01-01 are rejected', () => {
expect(() => {
convertForInsert(basicSchema, {}, 'transactions', {
id: 't1',
account: 'foo',
amount: 5,
date: '1999-12-31',
date: '1994-12-31',
});
}).toThrow('Invalid date: 1999-12-31');
}).toThrow('Invalid date: 1994-12-31');
expect(() => {
convertForInsert(basicSchema, {}, 'transactions', {
@@ -230,13 +230,13 @@ describe('schema-helpers', () => {
}).toThrow('Invalid date: 1900-01-01');
});
test('dates on or after 2000-01-01 are accepted', () => {
test('dates on or after 1995-01-01 are accepted', () => {
const trans = convertForInsert(basicSchema, {}, 'transactions', {
id: 't1',
account: 'foo',
amount: 5,
date: '2000-01-01',
date: '1995-01-01',
});
expect(trans.date).toBe(20000101);
expect(trans.date).toBe(19950101);
});
});

View File

@@ -25,7 +25,7 @@ export function convertInputType(value, type) {
return toDateRepr(dayFromDate(value));
} else if (
value.match(/^\d{4}-\d{2}-\d{2}$/) == null ||
value < '2000-01-01'
value < '1995-01-01'
) {
throw new Error('Invalid date: ' + value);
}