Skip to content

Commit

Permalink
Keep regex in memory
Browse files Browse the repository at this point in the history
  • Loading branch information
gruppler committed Dec 4, 2023
1 parent d76e059 commit c015bea
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/components/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@
function sendFormData () {
emit('searchEvent', formData.value)
}
const IDFieldRegex = /^(?!.*,,)(?!.*--)\d+([-,\d]*\d+)?$/;
function validateIDField(id: string): boolean {
resetFormValidation();
if(!id) {
return true;
}
const regex = /^(?!.*,,)(?!.*--)\d+([-,\d]*\d+)?$/;
if (!regex.test(id)) {
if (!IDFieldRegex.test(id)) {
setFormValidation('Invalid ID format (e.g. 123 | 123-456 | 123,456,789)');
return false;
}
Expand Down

0 comments on commit c015bea

Please sign in to comment.