Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added user input exception handling alerts for name and lengths #56

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,18 @@ export default{
//Event handlers
//receives search input events
handleSearch(searchInput) {
this.searchInput = searchInput;
this.applyAllFilters();
return this.searchInput;
let strRegex = new RegExp(/^[a-z\s]*$/i);
let result = strRegex.test(searchInput);
try {
if (!result) throw "Non-alphabetical name";
this.searchInput = searchInput;
this.applyAllFilters();
return this.searchInput;
}
catch(err) {
console.log('Invalid user input: ' + err);
alert('Invalid user input: ' + err);
}
},
//receives tag button events
handleTags(selectedTag) {
Expand Down Expand Up @@ -336,12 +345,27 @@ export default{
},
//generic size filter event handler
handleSizeFilter(filterData) {
this.stipeLen = filterData.stipeLen;
this.stipeDiam = filterData.stipeDiam;
this.capDiam = filterData.capDiam;
this.capThick = filterData.capThick;
this.applyAllFilters();
return this.filterData;
let strRegex = new RegExp(/^[0-9]*$/i);
const result = [];
result[0] = strRegex.test(filterData.stipeLen);
result[1] = strRegex.test(filterData.stipeDiam);
result[2] = strRegex.test(filterData.capDiam);
result[3] = strRegex.test(filterData.capThick);
try {
for (var i=0;i<4;i++) {
if (!result[i]) throw "Non-numerical length";
}
this.stipeLen = filterData.stipeLen;
this.stipeDiam = filterData.stipeDiam;
this.capDiam = filterData.capDiam;
this.capThick = filterData.capThick;
this.applyAllFilters();
return this.filterData;
}
catch(err) {
console.log('Invalid user input: ' + err);
alert('Invalid user input: ' + err);
}
},
//Open
openCarouselInputs() {
Expand Down
Loading