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

Refactor/refactor validation for emailAdress and website #122

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f95e9a6
refactor: email validation
RuthDiG Apr 16, 2024
6ddd188
fix: Email-Validation and add a test for it
RuthDiG May 6, 2024
64df3f4
fix: Website Validation and add a test for it
RuthDiG May 6, 2024
fde68a4
Merge remote-tracking branch 'origin/main' into refactor/refactor-val…
RuthDiG May 7, 2024
aa49e8a
feat: change regexp from Url
RuthDiG May 7, 2024
532278b
Merge branch 'main' into refactor/refactor-validation-for-AbstractEma…
mergify[bot] May 7, 2024
ea00966
chore: version bump
RuthDiG May 7, 2024
8b35b32
refactor: test for website
RuthDiG May 8, 2024
ee5b37b
refactor: changed wording of the test
RuthDiG May 13, 2024
7bf9bfd
refactor: Tests for Email and Website
RuthDiG May 14, 2024
76e95e1
refactor: change string in regexp
RuthDiG May 14, 2024
407b174
refactor: test for Website and AbstractURL
RuthDiG May 15, 2024
ef0e007
Merge branch 'main' into refactor/refactor-validation-for-AbstractEma…
RuthDiG May 16, 2024
24b3c14
refactor: name and AbstractURL without escape
RuthDiG May 16, 2024
73b6374
Merge branch 'main' into refactor/refactor-validation-for-AbstractEma…
RuthDiG Jun 4, 2024
a8fa603
refactor: Change Tests and RegExp
RuthDiG Jun 5, 2024
e045ae1
chore: version bump
RuthDiG Jun 5, 2024
2c2b4ed
feat: make regexp more readable
RuthDiG Jun 5, 2024
825bbee
fix: changed an error
RuthDiG Jun 5, 2024
5427a52
Merge branch 'main' into refactor/refactor-validation-for-AbstractEma…
mergify[bot] Jun 6, 2024
f1b4fdf
fix: error and last changes
RuthDiG Jun 6, 2024
151cfe4
Merge remote-tracking branch 'origin/main' into refactor/refactor-val…
RuthDiG Jun 7, 2024
b324923
feat: last changes
RuthDiG Jun 7, 2024
677088f
chore: version bump
RuthDiG Jun 7, 2024
0ce518a
fix: delete unnecessary file
RuthDiG Jun 7, 2024
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
2 changes: 1 addition & 1 deletion packages/content/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nmshd/content",
"version": "2.9.0",
"version": "2.9.1",
"description": "The content library defines data structures that can be transmitted using the transport library.",
"homepage": "https://enmeshed.eu",
"repository": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ export abstract class AbstractEMailAddress extends AbstractString {
@serialize()
@validate({
min: 3,
max: 100,
regExp: new RegExp("^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,}$", "i")
max: 254,
regExp: new RegExp(
/^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$/
)
})
public override value: string;

public static override get valueHints(): ValueHints {
return super.valueHints.copyWith({
min: 3,
max: 100,
pattern: "/^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,}$/i"
max: 254,
pattern:
"/^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$/"
});
}

Expand Down
5 changes: 2 additions & 3 deletions packages/content/src/attributes/types/strings/AbstractURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
min: 3,
max: 1024,
regExp: new RegExp(
// eslint-disable-next-line no-useless-escape
/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/
/^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved Hide resolved
)
})
public override value: string;
RuthDiG marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -19,7 +18,7 @@
min: 3,
max: 1024,
pattern:
"/((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\\+\\$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\+~%\\/.\\w\\-_]*)?\\??(?:[-\\+=&;%@.\\w_]*)#?(?:[\\w]*))?)/"
"/^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/"
});
}
RuthDiG marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
73 changes: 73 additions & 0 deletions packages/content/test/attributes/EMailAddress.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { ParsingError } from "@js-soft/ts-serval";
import { EMailAddress } from "../../src";

describe("creation of RepositoryAttributes of Attribute value type EMailAddress", function () {
test("can create a RepositoryAttribute of Attribute value type EMailAddress", function () {
const validEMailAddress = EMailAddress.from({
value: "peter123@inwind.it"
});
expect(validEMailAddress.value.toString()).toBe("peter123@inwind.it");
});
test("can create a RepositoryAttribute of Attribute value type EMailAddress with the German 'ä' in its domain", function () {
const validEMailAddress = EMailAddress.from({
value: "peter123@inwänd.it"
});
expect(validEMailAddress.value.toString()).toBe("peter123@inwänd.it");
});
test("returns an error when trying to create an Attribute value type EMailAddress with a blank in the value for EMailAddress", function () {
const invalidEMailAddressCall = () => {
EMailAddress.from({
value: "Hugo Becker@gmx.de"
});
};
expect(invalidEMailAddressCall).toThrow(
new ParsingError(
"EMailAddress",
"value",
"Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/"
)
);
});
test("returns an error when trying to create an Attribute value type EMailAddress without the right ending in the value for EMailAddress", function () {
const invalidEMailAddressCall = () => {
EMailAddress.from({
value: "Becker@gmx"
});
};
expect(invalidEMailAddressCall).toThrow(
new ParsingError(
"EMailAddress",
"value",
"Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/"
)
);
});
test("returns an error when trying to create an Attribute value type EMailAddress with a domain which ends with a - because this is not allowed for domains.", function () {
const invalidEMailAddressCall = () => {
EMailAddress.from({
value: "Becker@gmx-.de"
});
};
expect(invalidEMailAddressCall).toThrow(
new ParsingError(
"EMailAddress",
"value",
"Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/"
)
);
});
test("returns an error when trying to create an Attribute value type EMailAddress with a domain which begins with a - because this is not allowed for domains.", function () {
const invalidEMailAddressCall = () => {
EMailAddress.from({
value: "Becker@-gmx.de"
});
};
expect(invalidEMailAddressCall).toThrow(
new ParsingError(
"EMailAddress",
"value",
"Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/"
)
);
});
});
105 changes: 105 additions & 0 deletions packages/content/test/attributes/Website.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { ParsingError } from "@js-soft/ts-serval";
import { Website } from "../../src";

describe("creation of RepositoryAttributes of Attribute value type Website", function () {
RuthDiG marked this conversation as resolved.
Show resolved Hide resolved
test("can create a RepositoryAttribute of Attribute value type Website with the beginning www.", function () {
const validWebsite = Website.from({
value: "www.inwind.it"
});
expect(validWebsite.value.toString()).toBe("www.inwind.it");
});
test("can create a RepositoryAttribute of Attribute value type Website", function () {
const validWebsite = Website.from({
value: "https://inwind.it"
});
expect(validWebsite.value.toString()).toBe("https://inwind.it");
});
test("can create a RepositoryAttribute of Attribute value type Website with the German 'ä' in its domain", function () {
const validWebsite = Website.from({
value: "https://inwänd.it"
});
expect(validWebsite.value.toString()).toBe("https://inwänd.it");
});
test("can create a RepositoryAttribute of Attribute value type Website without www.", function () {
const validWebsite = Website.from({
value: "//google.it"
});
expect(validWebsite.value.toString()).toBe("//google.it");
});
RuthDiG marked this conversation as resolved.
Show resolved Hide resolved
test("can create a RepositoryAttribute of Attribute value type Website with an enhanced path", function () {
const validWebsite = Website.from({
value: "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/"
});
expect(validWebsite.value.toString()).toBe(
"https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/"
);
});
test("can create a RepositoryAttribute of Attribute value type Website with an encoded url", function () {
const validWebsite = Website.from({
value: "https://inwind.test/%20it/"
});
expect(validWebsite.value.toString()).toBe("https://inwind.test/%20it/");
});
test("can create a RepositoryAttribute of Attribute value type Website with a port ", function () {
const validWebsite = Website.from({
value: "https://example.org:8080/mein/ordner/bericht"
});
expect(validWebsite.value.toString()).toBe("https://example.org:8080/mein/ordner/bericht");
});
test("returns an error when trying to create an Attribute value type Website with a blank in the value for Website", function () {
const invalidWebsiteCall = () => {
Website.from({
value: "https://inwind.test it"
RuthDiG marked this conversation as resolved.
Show resolved Hide resolved
});
};
expect(invalidWebsiteCall).toThrow(
new ParsingError(
"Website",
"value",
"Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/"
)
);
});
test("returns an error when trying to create an Attribute value type Website without the right ending when it starts with www.", function () {
const invalidWebsiteCall = () => {
Website.from({
value: "www.google"
});
};
expect(invalidWebsiteCall).toThrow(
new ParsingError(
"Website",
"value",
"Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/"
)
);
});
test("returns an error when trying to create an Attribute value type Website with a domain which ends with a - because this is not allowed for domains.", function () {
const invalidWebsiteCall = () => {
Website.from({
value: "google-.de"
});
};
expect(invalidWebsiteCall).toThrow(
new ParsingError(
"Website",
"value",
"Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/"
)
);
});
test("returns an error when trying to create an Attribute value type Website with a domain which begins with a - because this is not allowed for domains.", function () {
const invalidWebsiteCall = () => {
Website.from({
value: "-google.de"
});
};
expect(invalidWebsiteCall).toThrow(
new ParsingError(
"Website",
"value",
"Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/"
)
);
});
});
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@js-soft/ts-serval": "2.0.10",
"@js-soft/ts-utils": "^2.3.3",
"@nmshd/consumption": "3.10.0",
"@nmshd/content": "2.9.0",
"@nmshd/content": "2.9.1",
"@nmshd/crypto": "2.0.6",
"@nmshd/transport": "2.6.0",
"ajv": "^8.13.0",
Expand Down