getzero11 commited on
Commit
a832eac
·
verified ·
1 Parent(s): 86c7474

Upload 2 files

Browse files
src/schema/dashboard.schema.js CHANGED
@@ -1,39 +1,18 @@
1
  export function validateDashboard(d) {
2
  if (!d) throw new Error("dashboard_view missing");
3
-
4
  if (!d.marketTitle) {
5
  throw new Error("dashboard_view.marketTitle missing");
6
  }
7
-
8
  if (!d.marketSummary) {
9
  throw new Error("dashboard_view.marketSummary missing");
10
  }
11
-
12
- const ms = d.marketSummary;
13
- requireNumber(ms.past2023, "past2023");
14
- requireNumber(ms.current2025, "current2025");
15
- requireNumber(ms.forecast2033, "forecast2033");
16
- requireNumber(ms.cagr, "cagr");
17
-
18
- if (!Array.isArray(d.forecast)) {
19
- throw new Error("dashboard_view.forecast must be array");
20
- }
21
-
22
- if (!Array.isArray(d.regional)) {
23
- throw new Error("dashboard_view.regional must be array");
24
- }
25
-
26
- if (!Array.isArray(d.segments)) {
27
- throw new Error("dashboard_view.segments must be array");
28
- }
29
-
30
- if (!Array.isArray(d.competitive)) {
31
- throw new Error("dashboard_view.competitive must be array");
32
  }
33
  }
 
34
 
35
- function requireNumber(value, name) {
36
- if (typeof value !== "number" || Number.isNaN(value)) {
37
- throw new Error(`dashboard_view.marketSummary.${name} must be number`);
38
- }
39
- }
 
1
  export function validateDashboard(d) {
2
  if (!d) throw new Error("dashboard_view missing");
3
+
4
  if (!d.marketTitle) {
5
  throw new Error("dashboard_view.marketTitle missing");
6
  }
7
+
8
  if (!d.marketSummary) {
9
  throw new Error("dashboard_view.marketSummary missing");
10
  }
11
+
12
+ // Basic validation only
13
+ if (!Array.isArray(d.marketSegments)) {
14
+ throw new Error("dashboard_view.marketSegments must be array");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
  }
17
+
18
 
 
 
 
 
 
src/schema/report.schema.js CHANGED
@@ -1,35 +1,22 @@
1
  export function validateReport(r) {
2
  if (!r) throw new Error("report_view missing");
3
-
4
  if (!r.marketTitle) {
5
  throw new Error("report_view.marketTitle missing");
6
  }
7
-
8
- if (!r.marketSizing) {
9
- throw new Error("report_view.marketSizing missing");
10
  }
11
-
12
- const ms = r.marketSizing;
13
- requireNumber(ms.pastYear_2023, "pastYear_2023");
14
- requireNumber(ms.currentYear_2025, "currentYear_2025");
15
- requireNumber(ms.forecastYear_2033, "forecastYear_2033");
16
- requireNumber(ms.global_cagr_Forecast, "global_cagr_Forecast");
17
-
18
  if (!Array.isArray(r.marketSegments)) {
19
  throw new Error("report_view.marketSegments must be array");
20
  }
21
-
22
- if (!Array.isArray(r.marketDrivers)) {
23
- throw new Error("report_view.marketDrivers must be array");
24
- }
25
-
26
- if (!Array.isArray(r.strategicRecommendations)) {
27
- throw new Error("report_view.strategicRecommendations must be array");
28
- }
29
  }
 
30
 
31
- function requireNumber(value, name) {
32
- if (typeof value !== "number" || Number.isNaN(value)) {
33
- throw new Error(`report_view.marketSizing.${name} must be number`);
34
- }
35
- }
 
1
  export function validateReport(r) {
2
  if (!r) throw new Error("report_view missing");
3
+
4
  if (!r.marketTitle) {
5
  throw new Error("report_view.marketTitle missing");
6
  }
7
+
8
+ if (!r.marketOverview) {
9
+ throw new Error("report_view.marketOverview missing");
10
  }
11
+
12
+ const mo = r.marketOverview;
13
+ if (typeof mo.pastYear_2023 !== 'number') throw new Error("pastYear_2023 must be number");
14
+ if (typeof mo.currentYear_2025 !== 'number') throw new Error("currentYear_2025 must be number");
15
+
16
+ // Basic validation only
 
17
  if (!Array.isArray(r.marketSegments)) {
18
  throw new Error("report_view.marketSegments must be array");
19
  }
 
 
 
 
 
 
 
 
20
  }
21
+
22