-
-
-
-
- {{ translatedErrorString }}
-
-
-
-
-
-
-
-
diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json
index 8b441b982..a94099015 100644
--- a/frontend/src/locales/de.json
+++ b/frontend/src/locales/de.json
@@ -203,6 +203,11 @@
"username": "Benutzername",
"username-placeholder": "Wähle deinen Benutzernamen",
"validation": {
+ "amount": {
+ "min": "Der Betrag sollte mindestens {min} groß sein",
+ "max": "Der Betrag sollte höchstens {max} groß sein",
+ "decimal-places": "Der Betrag sollte maximal zwei Nachkommastellen enthalten"
+ },
"gddCreationTime": {
"min": "Die Stunden sollten mindestens {min} groß sein",
"max": "Die Stunden sollten höchstens {max} groß sein",
diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json
index ca4877682..ec26e866d 100644
--- a/frontend/src/locales/en.json
+++ b/frontend/src/locales/en.json
@@ -203,6 +203,11 @@
"username": "Username",
"username-placeholder": "Choose your username",
"validation": {
+ "amount": {
+ "min": "The amount should be at least {min} in size",
+ "max": "The amount should not be larger than {max}",
+ "decimal-places": "The amount should contain a maximum of two decimal places"
+ },
"gddCreationTime": {
"min": "The hours should be at least {min} in size",
"max": "The hours should not be larger than {max}",
diff --git a/frontend/src/validationSchemas.js b/frontend/src/validationSchemas.js
index 01a1ec8ab..9c21aec66 100644
--- a/frontend/src/validationSchemas.js
+++ b/frontend/src/validationSchemas.js
@@ -1,4 +1,10 @@
import { string } from 'yup'
+import { validate as validateUuid, version as versionUuid } from 'uuid'
+
+// Email and username regex patterns remain the same
+const EMAIL_REGEX =
+ /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
+const USERNAME_REGEX = /^(?=.{3,20}$)[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9]+?)*$/
// TODO: only needed for grace period, before all inputs updated for using veeValidate + yup
export const isLanguageKey = (str) =>
@@ -19,3 +25,15 @@ export const memo = string()
.required('contribution.yourActivity')
.min(5, ({ min }) => ({ key: 'form.validation.memo.min', values: { min } }))
.max(255, ({ max }) => ({ key: 'form.validation.memo.max', values: { max } }))
+
+export const identifier = string().test(
+ 'valid-identifier',
+ 'form.validation.valid-identifier',
+ (value) => {
+ const isEmail = !!EMAIL_REGEX.test(value)
+ const isUsername = !!value.match(USERNAME_REGEX)
+ // TODO: use valibot and rules from shared
+ const isGradidoId = validateUuid(value) && versionUuid(value) === 4
+ return isEmail || isUsername || isGradidoId
+ },
+)