🌐 App validation errors

This commit is contained in:
Tagaishi
2023-08-13 22:24:46 +02:00
parent 7c898379e8
commit a973265795
2 changed files with 13 additions and 7 deletions

View File

@@ -99,6 +99,12 @@
} }
}, },
"validation": { "validation": {
"popover": "Your form contains invalid data. Hence, it can't be saved. Please resolve all issues and click this button again to save your changes" "popover": "Your form contains invalid data. Hence, it can't be saved. Please resolve all issues and click this button again to save your changes",
"name": "Name is required",
"noUrl": "Url is required",
"invalidUrl": "Value is not a valid url",
"noIconUrl": "This field is required",
"noExternalUri": "External URI is required",
"invalidExternalUri": "External URI is not a valid uri"
} }
} }

View File

@@ -47,14 +47,14 @@ export const EditAppModal = ({
const form = useForm<AppType>({ const form = useForm<AppType>({
initialValues: innerProps.app, initialValues: innerProps.app,
validate: { validate: {
name: (name) => (!name ? 'Name is required' : null), name: (name) => (!name ? t('validation.name') : null),
url: (url) => { url: (url) => {
if (!url) { if (!url) {
return 'Url is required'; return t('validation.noUrl');
} }
if (!url.match(appUrlRegex)) { if (!url.match(appUrlRegex)) {
return 'Value is not a valid url'; return t('validation.invalidUrl');
} }
return null; return null;
@@ -62,7 +62,7 @@ export const EditAppModal = ({
appearance: { appearance: {
iconUrl: (url: string) => { iconUrl: (url: string) => {
if (url.length < 1) { if (url.length < 1) {
return 'This field is required'; return t('validation.noIconUrl');
} }
return null; return null;
@@ -71,11 +71,11 @@ export const EditAppModal = ({
behaviour: { behaviour: {
externalUrl: (url: string) => { externalUrl: (url: string) => {
if (url === undefined || url.length < 1) { if (url === undefined || url.length < 1) {
return 'External URI is required'; return t('validation.noExternalUri');
} }
if (!url.match(appUrlWithAnyProtocolRegex)) { if (!url.match(appUrlWithAnyProtocolRegex)) {
return 'External URI is not a valid uri'; return t('validation.invalidExternalUri');
} }
return null; return null;