diff --git a/frontend/src/app/validators/keywords.validator.ts b/frontend/src/app/validators/keywords.validator.ts index 0166374..a86cfc3 100644 --- a/frontend/src/app/validators/keywords.validator.ts +++ b/frontend/src/app/validators/keywords.validator.ts @@ -1,6 +1,19 @@ import {AbstractControl} from '@angular/forms'; export function keywordsValidator(control: AbstractControl): { [key: string]: any } | null { - const valid = /^((\w){3,},?){1,2}(\w{3,})?$/.test(control.value); - return valid ? null : {'invalidKeywords': {value: control.value}}; + if (control.value == undefined) { + return null; + } + let split: string[]; + split = control.value.split(','); + if (split.length > 3) { + return {'invalidKeywords': {value: control.value}}; + } + for (let i = 0; i < split.length; i++) { + const word = split[i].trim(); + if (word.length < 3) { + return {'invalidKeywords': {value: control.value}}; + } + } + return null; }