bpmnlint-plugin-camunda-compat 0.13.0 → 0.13.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,14 @@
1
- const ISO_DATE_REGEX = /^\d{4}(-\d\d){2}T(\d\d:){2}\d\d(Z|([+-]\d\d:\d\d)(\[\w+\/\w+\])?)?$/;
1
+ const YEAR = '\\d{4}';
2
+ const MONTH = '(?<month>0[1-9]|1[0-2])';
3
+ const DAY = '(0[1-9]|[12][0-9]|3[01])';
4
+ const DATE = `(?<date>${YEAR}-${MONTH}-${DAY})`;
5
+ const HOUR = '(0[0-9]|1[0-9]|2[0-3])';
6
+ const MINUTE = '[0-5][0-9]';
7
+ const SECOND = '[0-5][0-9]';
8
+ const ZONE_ID = '(\\[[^\\]]+\\])';
9
+ const TIMEZONE = `(Z|([+-](0[0-9]|1[0-3]):[0-5][0-9]${ZONE_ID}?))`;
10
+
11
+ const ISO_DATE_REGEX = new RegExp(`^${DATE}T${HOUR}:${MINUTE}:${SECOND}${TIMEZONE}$`);
2
12
  const ISO_DURATION = 'P(?!$)(\\d+(\\.\\d+)?[Yy])?(\\d+(\\.\\d+)?[Mm])?(\\d+(\\.\\d+)?[Dd])?(T(?!$)(\\d+(\\.\\d+)?[Hh])?(\\d+(\\.\\d+)?[Mm])?(\\d+(\\.\\d+)?[Ss])?)?$';
3
13
  const ISO_DURATION_REGEX = new RegExp(`^${ISO_DURATION}$`);
4
14
  const ISO_CYCLE = `R(-1|\\d+)?/${ISO_DURATION}`;
@@ -15,9 +25,27 @@ function validateCycle(value) {
15
25
  }
16
26
 
17
27
  function validateDate(value) {
18
- return ISO_DATE_REGEX.test(value);
28
+ const result = ISO_DATE_REGEX.exec(value);
29
+
30
+ if (!result) {
31
+ return false;
32
+ }
33
+
34
+ return isDateValid(result);
19
35
  }
20
36
 
21
37
  function validateDuration(value) {
22
38
  return ISO_DURATION_REGEX.test(value);
23
39
  }
40
+
41
+ function isDateValid(result) {
42
+ const {
43
+ date,
44
+ month
45
+ } = result.groups;
46
+
47
+ const dateParsedMonth = new Date(date).getMonth() + 1;
48
+ const parsedMonth = Number.parseInt(month, 10);
49
+
50
+ return dateParsedMonth === parsedMonth;
51
+ }