commit 6f5aaaf1219060350567fa24ebb32f0c2eca27d9
parent f6335adbf9611e9969ee82851e87f97fff5b1dca
Author: Sebastian <sebasjm@gmail.com>
Date: Mon, 19 May 2025 15:52:12 -0300
fix #9979
Diffstat:
6 files changed, 61 insertions(+), 31 deletions(-)
diff --git a/packages/web-util/src/forms/gana/GLS_Onboarding.ts b/packages/web-util/src/forms/gana/GLS_Onboarding.ts
@@ -1,5 +1,5 @@
import { TalerFormAttributes } from "@gnu-taler/taler-util";
-import { intervalToDuration, isFuture, parse } from "date-fns";
+import { intervalToDuration, isFuture, isValid, parse } from "date-fns";
import {
DoubleColumnFormDesign,
InternationalizationAPI,
@@ -44,12 +44,15 @@ export function GLS_Onboarding(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
if ( years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
@@ -153,12 +156,15 @@ export function GLS_Onboarding(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
if ( years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
diff --git a/packages/web-util/src/forms/gana/VQF_902_1_customer.ts b/packages/web-util/src/forms/gana/VQF_902_1_customer.ts
@@ -15,7 +15,7 @@
*/
import { TalerFormAttributes } from "@gnu-taler/taler-util";
-import { intervalToDuration, isFuture, parse } from "date-fns";
+import { intervalToDuration, isDate, isFuture, isValid, parse } from "date-fns";
import {
DoubleColumnFormDesign,
InternationalizationAPI,
@@ -139,14 +139,17 @@ export function design_VQF_902_1_customer(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
- if ( years && years > 120) {
+ if (years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
}
return undefined;
@@ -297,17 +300,20 @@ export function design_VQF_902_1_customer(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
- if ( years && years > 120) {
+ if (years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
}
- return undefined;
+ return undefined;
},
},
{
diff --git a/packages/web-util/src/forms/gana/VQF_902_1_officer.ts b/packages/web-util/src/forms/gana/VQF_902_1_officer.ts
@@ -15,7 +15,7 @@
*/
import { TalerFormAttributes } from "@gnu-taler/taler-util";
-import { format, intervalToDuration, isFuture, isToday, parse } from "date-fns";
+import { format, intervalToDuration, isFuture, isToday, isValid, parse } from "date-fns";
import {
DoubleColumnFormDesign,
FormMetadata,
@@ -127,12 +127,15 @@ export function VQF_902_1_officer(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
if ( years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
diff --git a/packages/web-util/src/forms/gana/VQF_902_4.ts b/packages/web-util/src/forms/gana/VQF_902_4.ts
@@ -4,7 +4,7 @@ import {
FormMetadata,
InternationalizationAPI,
} from "../../index.browser.js";
-import { intervalToDuration, parse, isFuture } from "date-fns";
+import { intervalToDuration, parse, isFuture, isValid } from "date-fns";
export const form_vqf_902_4 = (
i18n: InternationalizationAPI,
@@ -87,12 +87,15 @@ export function VQF_902_4(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
if (years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
@@ -141,12 +144,15 @@ export function VQF_902_4(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
if (years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
@@ -378,12 +384,15 @@ export function VQF_902_4(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
if (years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
diff --git a/packages/web-util/src/forms/gana/VQF_902_9_customer.ts b/packages/web-util/src/forms/gana/VQF_902_9_customer.ts
@@ -5,7 +5,7 @@ import {
InternationalizationAPI,
} from "../../index.browser.js";
import { countryNationalityList } from "../../utils/select-ui-lists.js";
-import { format, intervalToDuration, isFuture, parse } from "date-fns";
+import { format, intervalToDuration, isFuture, isValid, parse } from "date-fns";
export const form_vqf_902_9_customer = (
i18n: InternationalizationAPI,
@@ -74,14 +74,17 @@ export function VQF_902_9_customer(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
- if (years && years > 120) {
+ if (years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
}
return undefined;
diff --git a/packages/web-util/src/forms/gana/VQF_902_9_officer.ts b/packages/web-util/src/forms/gana/VQF_902_9_officer.ts
@@ -5,7 +5,7 @@ import {
InternationalizationAPI,
} from "../../index.browser.js";
import { countryNationalityList } from "../../utils/select-ui-lists.js";
-import { intervalToDuration, isFuture, parse } from "date-fns";
+import { intervalToDuration, isFuture, isValid, parse } from "date-fns";
export const form_vqf_902_9_officer = (
i18n: InternationalizationAPI,
@@ -72,14 +72,17 @@ export function VQF_902_9_officer(
validator(text, form) {
//FIXME: why returning in this format even if pattern is in another?
const time = parse(text, "yyyy-MM-dd", new Date());
+ if (!isValid(time)) {
+ return i18n.str`invalid format`;
+ }
if (isFuture(time)) {
return i18n.str`it can't be in the future`;
}
const { years } = intervalToDuration({
- start: new Date(),
- end: time,
+ start: time,
+ end: new Date(),
});
- if (years && years > 120) {
+ if (years && years > 120) {
return i18n.str`it can't be greater than 120 years`;
}
return undefined;