Skip to content

Commit 1e455da

Browse files
authored
Merge pull request #20 from kkj930/master
3A Reviews: Add validation: Name is required. Must accept the terms.
2 parents 072755c + 0191aad commit 1e455da

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

cli-socks/src/components/ProductReview.vue

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<label>Name</label>
55
<input v-model="name" @keydown.ctrl.v.prevent="blockPaste">
66

7-
<div class="error" v-for="error in errors" :key="error">
8-
* {{ error }}
9-
</div>
10-
7+
<ul class="error" v-for="error in errors" :key="error">
8+
<li>{{error}}</li>
9+
</ul>
10+
1111
<label>Rating</label>
1212
<select v-model.number="rating">
1313
<option disabled value="">select</option>
@@ -45,10 +45,18 @@ export default class ProductReview extends Vue {
4545
this.errors = [];
4646
if (!this.rating) {
4747
this.errors.push('Please select a rating');
48+
}
49+
if (!this.name) {
50+
this.errors.push('Please provide your name');
51+
}
52+
if (!this.acceptTerms) {
53+
this.errors.push('Please accept the terms');
54+
}
55+
if (this.errors.length) {
4856
return;
4957
}
5058
51-
const review = {name: this.name, rating: this.rating}
59+
const review = {name: this.name, rating: this.rating};
5260
console.log('Submitting', review);
5361
this.$emit('add-review', review);
5462
}
@@ -72,7 +80,7 @@ h3 {
7280
}
7381

7482
input:not([type=checkbox]) {
75-
width: 100%;
83+
width: 100%;
7684
height: 25px;
7785
margin-bottom: 10px;
7886
}

0 commit comments

Comments
 (0)