Skip to content

Commit

Permalink
Remove unnecessary dependency between domain layer and utilities, add…
Browse files Browse the repository at this point in the history
… test
  • Loading branch information
Arciiix committed Jul 17, 2024
1 parent 8a9dbcf commit b1d331f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public void Should_fail_if_url_is_invalid(string? input)
}

[Theory]
[InlineData("http://192.168.0.101/")]
[InlineData("http://localhost/test")]
[InlineData("https://example.com/test?query=example")]
[InlineData("http://login:password@test.pl/random")]
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/app/pages/integrations/IntegrationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@ export const IntegrationDialog = (props: IntegrationDialogProps) => {
}

if (property.format && property.format !== "None") {
propertyType = propertyType.formatI18n(property.format);
switch (property.format) {
case "Email":
propertyType = propertyType.emailI18n();
break;
case "Url":
propertyType = propertyType.urlI18n();
break;
}
}

if (property.pattern) {
Expand Down
13 changes: 0 additions & 13 deletions frontend/src/app/shared/utils/yup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import * as Yup from 'yup';
import { Types } from '@app/framework';
import { texts } from '@app/texts';
import { PropertyFormat } from '@app/service';

function emailI18n(this: Yup.StringSchema) {
return this.email(texts.validation.emailFn);
Expand Down Expand Up @@ -61,25 +60,13 @@ function atLeastOneStringI18n(this: Yup.ObjectSchema<any>) {
});
}

function formatI18n(this: Yup.StringSchema, format: PropertyFormat) {
switch (format) {
case "Email":
return this.emailI18n();
case "Url":
return this.urlI18n();
default:
return this;
}
}

export function extendYup() {
Yup.addMethod(Yup.object, 'atLeastOneStringI18n', atLeastOneStringI18n);

Yup.addMethod(Yup.string, 'emailI18n', emailI18n);
Yup.addMethod(Yup.string, 'urlI18n', urlI18n);
Yup.addMethod(Yup.string, 'requiredI18n', requiredI18n);
Yup.addMethod(Yup.string, 'topicI18n', topicI18n);
Yup.addMethod(Yup.string, 'formatI18n', formatI18n);

Yup.addMethod(Yup.number, 'maxI18n', maxI18N);
Yup.addMethod(Yup.number, 'minI18n', minI18N);
Expand Down

0 comments on commit b1d331f

Please sign in to comment.