Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
chore(ontology): better regex for onto name (DSP-1139) (#488)
* chore(ontology): better regex for onto name (DSP-1139)

* test(onto): test new onto name regex (DSP-1139)

* chore(ontology): better regex for onto name (DSP-1139)
  • Loading branch information
kilchenmann committed Jul 20, 2021
1 parent ce51bce commit ec881ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Expand Up @@ -136,7 +136,13 @@ describe('OntologyFormComponent', () => {
expect(form.valid).toBeFalsy();

nameInput.setValue('my-onto');
expect(form.valid).toBeFalsy();
expect(form.valid).toBeTruthy();

nameInput.setValue('my_onto');
expect(form.valid).toBeTruthy();

nameInput.setValue('my.onto');
expect(form.valid).toBeTruthy();

nameInput.setValue('2ndOnto');
expect(form.valid).toBeFalsy();
Expand All @@ -147,15 +153,6 @@ describe('OntologyFormComponent', () => {
nameInput.setValue('_notAllowed');
expect(form.valid).toBeFalsy();

nameInput.setValue('not-allowed');
expect(form.valid).toBeFalsy();

nameInput.setValue('not_allowed');
expect(form.valid).toBeFalsy();

nameInput.setValue('not.allowed');
expect(form.valid).toBeFalsy();

nameInput.setValue('no$or€');
expect(form.valid).toBeFalsy();

Expand Down
Expand Up @@ -52,7 +52,7 @@ export class OntologyFormComponent implements OnInit {
lastModificationDate: string;

// regex to check ontology name: shouldn't start with a number or with 'v' followed by a number, spaces or special characters are not allowed
nameRegex = /^(?![vV]+[0-9])+^([a-zA-Z])[a-zA-Z0-9]*$/;
nameRegex = /^(?![vV]+[0-9])+^([a-zA-Z])[a-zA-Z0-9_.-]*$/;

// ontology name must not contain one of the following words
forbiddenNames: string[] = [
Expand Down

0 comments on commit ec881ef

Please sign in to comment.