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

chore(ontology): better regex for onto name (DSP-1139) #488

Merged
merged 3 commits into from Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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