mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
🌐 App validation errors
This commit is contained in:
@@ -99,6 +99,12 @@
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,14 +47,14 @@ export const EditAppModal = ({
|
||||
const form = useForm<AppType>({
|
||||
initialValues: innerProps.app,
|
||||
validate: {
|
||||
name: (name) => (!name ? 'Name is required' : null),
|
||||
name: (name) => (!name ? t('validation.name') : null),
|
||||
url: (url) => {
|
||||
if (!url) {
|
||||
return 'Url is required';
|
||||
return t('validation.noUrl');
|
||||
}
|
||||
|
||||
if (!url.match(appUrlRegex)) {
|
||||
return 'Value is not a valid url';
|
||||
return t('validation.invalidUrl');
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -62,7 +62,7 @@ export const EditAppModal = ({
|
||||
appearance: {
|
||||
iconUrl: (url: string) => {
|
||||
if (url.length < 1) {
|
||||
return 'This field is required';
|
||||
return t('validation.noIconUrl');
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -71,11 +71,11 @@ export const EditAppModal = ({
|
||||
behaviour: {
|
||||
externalUrl: (url: string) => {
|
||||
if (url === undefined || url.length < 1) {
|
||||
return 'External URI is required';
|
||||
return t('validation.noExternalUri');
|
||||
}
|
||||
|
||||
if (!url.match(appUrlWithAnyProtocolRegex)) {
|
||||
return 'External URI is not a valid uri';
|
||||
return t('validation.invalidExternalUri');
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user