@afeefa/vue-app 0.0.81 → 0.0.82

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.
@@ -1 +1 @@
1
- 0.0.81
1
+ 0.0.82
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.81",
3
+ "version": "0.0.82",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -14,6 +14,7 @@
14
14
  :style="cwm_widthStyle"
15
15
  v-bind="{...$attrs, ...attrs}"
16
16
  :rules="validationRules"
17
+ :error-messages="errorMessages"
17
18
  :readonly="type === 'month'"
18
19
  v-on="on"
19
20
  @input="dateInputChanged"
@@ -45,6 +46,7 @@ import { ComponentWidthMixin } from './mixins/ComponentWidthMixin'
45
46
  export default class ADatePicker extends Mixins(ComponentWidthMixin) {
46
47
  value_ = null
47
48
  menu = false
49
+ errorMessages = []
48
50
 
49
51
  created () {
50
52
  if (this.value) {
@@ -65,6 +67,21 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
65
67
  this.value_ = this.value
66
68
  }
67
69
 
70
+ @Watch('value_')
71
+ value_Changed () { // validate on any change
72
+ this.errorMessages = []
73
+ if (this.validator) {
74
+ const rules = this.validator.getRules(this.label)
75
+ for (const rule of rules) {
76
+ const message = rule(this.value_)
77
+ if (typeof message === 'string') {
78
+ this.errorMessages.push(message)
79
+ break
80
+ }
81
+ }
82
+ }
83
+ }
84
+
68
85
  get date () {
69
86
  return this.value_
70
87
  ? this.value_.toISOString().substr(0, this.type === 'month' ? 7 : 10)
@@ -112,23 +129,15 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
112
129
  }
113
130
 
114
131
  get validationRules () {
115
- const dateFormat = v => {
116
- if (v && !this.isDate(v)) {
117
- return 'Das Datum sollte das Format TT.MM.JJJJ haben.'
118
- }
119
- return true
120
- }
121
-
122
- let rules = []
123
- if (this.validator) {
124
- rules = this.validator.getRules(this.label)
125
- }
126
-
127
132
  if (this.type !== 'month') {
128
- rules.push(dateFormat)
133
+ const dateFormat = v => {
134
+ if (v && !this.isDate(v)) {
135
+ return 'Das Datum sollte das Format TT.MM.JJJJ haben.'
136
+ }
137
+ return true
138
+ }
139
+ return [dateFormat]
129
140
  }
130
-
131
- return rules
132
141
  }
133
142
  }
134
143
  </script>