@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.95 → 2.4.2-dev.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Site.js +34 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shisyamo4131/air-guard-v2-schemas",
3
- "version": "2.4.2-dev.95",
3
+ "version": "2.4.2-dev.97",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/Site.js CHANGED
@@ -20,6 +20,7 @@ import AgreementV2 from "./AgreementV2.js";
20
20
  import { VALUES } from "./constants/site-status.js";
21
21
  import { GeocodableMixin } from "./mixins/GeocodableMixin.js";
22
22
  import { formatJstDate } from "./utils/index.js";
23
+ import { VALIDATION_ERRORS } from "./errorDefinitions.js";
23
24
 
24
25
  const classProps = {
25
26
  customerId: defField("customerId", {
@@ -57,10 +58,38 @@ const classProps = {
57
58
  building: defField("building"),
58
59
  securityType: defField("securityType", { required: true }),
59
60
  constructionPeriodStartAt: defField("constructionPeriodStartAt", {
60
- component: { attrs: { clearable: true } },
61
+ validator: (value, item) => {
62
+ if (!value || !item.constructionPeriodEndAt) return true;
63
+ if (value > item.constructionPeriodEndAt) {
64
+ return VALIDATION_ERRORS.CUSTOM_ERROR(
65
+ "CONSTRUCTION_PERIOD_START_AT_MUST_BE_BEFORE_END_AT",
66
+ "工期開始日は工期終了日以前の日付を指定してください。",
67
+ );
68
+ }
69
+ return true;
70
+ },
71
+ component: {
72
+ attrs: {
73
+ clearable: true,
74
+ },
75
+ },
61
76
  }),
62
77
  constructionPeriodEndAt: defField("constructionPeriodEndAt", {
63
- component: { attrs: { clearable: true } },
78
+ validator: (value, item) => {
79
+ if (!value || !item.constructionPeriodStartAt) return true;
80
+ if (value < item.constructionPeriodStartAt) {
81
+ return VALIDATION_ERRORS.CUSTOM_ERROR(
82
+ "CONSTRUCTION_PERIOD_END_AT_MUST_BE_AFTER_START_AT",
83
+ "工期終了日は工期開始日以降の日付を指定してください。",
84
+ );
85
+ }
86
+ return true;
87
+ },
88
+ component: {
89
+ attrs: {
90
+ clearable: true,
91
+ },
92
+ },
64
93
  }),
65
94
  location: defField("location"),
66
95
  remarks: defField("remarks"),
@@ -247,7 +276,9 @@ export default class Site extends GeocodableMixin(FireModel) {
247
276
  configurable: true,
248
277
  enumerable: true,
249
278
  get() {
250
- return this.constructionPeriodStartAt || this.constructionPeriodEndAt;
279
+ return (
280
+ !!this.constructionPeriodStartAt || !!this.constructionPeriodEndAt
281
+ );
251
282
  },
252
283
  set() {},
253
284
  },