commit e42a7c6cce2a327a8169fba7143c9d229c3c92b9
parent 6a55ff52c9fc224595475e3a6fb39326cc42c920
Author: Sebastian <sebasjm@gmail.com>
Date: Tue, 20 Jul 2021 11:44:53 -0300
adding regex to instance id
Diffstat:
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/packages/frontend/src/paths/admin/create/CreatePage.tsx b/packages/frontend/src/paths/admin/create/CreatePage.tsx
@@ -28,7 +28,7 @@ import { SetTokenNewInstanceModal } from "../../../components/modal";
import { MerchantBackend } from "../../../declaration";
import { Translate, useTranslator } from "../../../i18n";
import { DefaultInstanceFormFields } from "../../../components/instance/DefaultInstanceFormFields";
-import { PAYTO_REGEX } from "../../../utils/constants";
+import { INSTANCE_ID_REGEX, PAYTO_REGEX } from "../../../utils/constants";
import { Amounts } from "@gnu-taler/taler-util";
export type Entity = MerchantBackend.Instances.InstanceConfigurationMessage & { auth_token?: string }
@@ -60,7 +60,7 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
const i18n = useTranslator()
const errors: FormErrors<Entity> = {
- id: !value.id ? i18n`required` : undefined,
+ id: !value.id ? i18n`required` : ( !INSTANCE_ID_REGEX.test(value.id) ? i18n`is not valid` : undefined),
name: !value.name ? i18n`required` : undefined,
payto_uris:
!value.payto_uris || !value.payto_uris.length ? i18n`required` : (
diff --git a/packages/frontend/src/utils/constants.ts b/packages/frontend/src/utils/constants.ts
@@ -42,4 +42,6 @@ export const MAX_RESULT_SIZE = PAGE_SIZE * 2 - 1;
// how much we will wait for all request, in seconds
export const DEFAULT_REQUEST_TIMEOUT = 10;
-export const MAX_IMAGE_SIZE = 1024 * 1024;
-\ No newline at end of file
+export const MAX_IMAGE_SIZE = 1024 * 1024;
+
+export const INSTANCE_ID_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9_.@-]+$/