Skip to content

Commit a1fa418

Browse files
committed
60
1 parent 274b1c6 commit a1fa418

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

db.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,22 @@
9090
"id": 25
9191
},
9292
{
93-
"subject": "dgdsfg",
93+
"subject": "123123",
9494
"completed": false,
9595
"body": "dfghdfgh",
9696
"id": 26
97+
},
98+
{
99+
"subject": "",
100+
"completed": false,
101+
"body": "",
102+
"id": 27
103+
},
104+
{
105+
"subject": "ab",
106+
"completed": false,
107+
"body": "",
108+
"id": 28
97109
}
98110
]
99111
}

src/components/TodoForm.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
type="text"
1616
class="form-control"
1717
>
18+
<div
19+
v-if="subjectError"
20+
style="color: red"
21+
>
22+
{{subjectError}}
23+
</div>
1824
</div>
1925
</div>
2026
<div v-if="editing" class="col-6">
@@ -87,6 +93,7 @@ export default {
8793
completed: false,
8894
body: ''
8995
});
96+
const subjectError = ref('');
9097
const originalTodo = ref(null);
9198
const loading = ref(false);
9299
const {
@@ -135,6 +142,12 @@ export default {
135142
}
136143
137144
const onSave = async () => {
145+
subjectError.value = '';
146+
if (!todo.value.subject) {
147+
subjectError.value = 'Subject is required';
148+
return;
149+
}
150+
138151
try {
139152
let res;
140153
const data = {
@@ -173,6 +186,7 @@ export default {
173186
showToast,
174187
toastMessage,
175188
toastAlertType,
189+
subjectError,
176190
};
177191
}
178192
}

0 commit comments

Comments
 (0)