File tree Expand file tree Collapse file tree 5 files changed +9
-0
lines changed
core/validation/src/main/java/com/shifthackz/aisdv1/core/validation/url
java/com/shifthackz/aisdv1/presentation/screen/setup Expand file tree Collapse file tree 5 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -10,5 +10,6 @@ interface UrlValidator {
1010 object Empty : Error
1111 object BadScheme : Error
1212 object Invalid : Error
13+ object Localhost : Error
1314 }
1415}
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ class UrlValidatorImpl : UrlValidator {
1919 isValid = false ,
2020 validationError = UrlValidator .Error .BadScheme ,
2121 )
22+ input.contains(LOCALHOST_IPV4 ) -> ValidationResult (
23+ isValid = false ,
24+ validationError = UrlValidator .Error .Localhost ,
25+ )
2226 ! URLUtil .isValidUrl(input) -> ValidationResult (
2327 isValid = false ,
2428 validationError = UrlValidator .Error .Invalid ,
@@ -33,5 +37,6 @@ class UrlValidatorImpl : UrlValidator {
3337 companion object {
3438 private const val SCHEME_HTTPS = " https://"
3539 private const val SCHEME_HTTP = " http://"
40+ private const val LOCALHOST_IPV4 = " 127.0.0.1"
3641 }
3742}
Original file line number Diff line number Diff line change @@ -67,5 +67,6 @@ fun ValidationResult<UrlValidator.Error>.mapToUi(): UiText? {
6767 UrlValidator .Error .BadScheme -> R .string.error_invalid_scheme
6868 UrlValidator .Error .Empty -> R .string.error_empty_url
6969 UrlValidator .Error .Invalid -> R .string.error_invalid_url
70+ UrlValidator .Error .Localhost -> R .string.error_localhost_url
7071 }.asUiText()
7172}
Original file line number Diff line number Diff line change 144144 <string name =" error_invalid" >Неправильні дані</string >
145145 <string name =" error_invalid_scheme" >URL має починатися з <b >http://</b > або <b >https://</b ></string >
146146 <string name =" error_invalid_url" >Недійсна URL-адреса сервера</string >
147+ <string name =" error_localhost_url" >Ви не можете використовувати localhost (127.0.0.1) URL-адресу для підключення до сервера.</string >
147148 <string name =" error_min_size" >Мінімальний розмір %1$s</string >
148149 <string name =" error_max_size" >Максимальний розмір %1$s</string >
149150</resources >
Original file line number Diff line number Diff line change 144144 <string name =" error_invalid" >Invalid input</string >
145145 <string name =" error_invalid_scheme" >Server URL should start with <b >http://</b > or <b >https://</b ></string >
146146 <string name =" error_invalid_url" >Invalid Server URL</string >
147+ <string name =" error_localhost_url" >You can not use localhost (127.0.0.1) URL to connect to server.</string >
147148 <string name =" error_min_size" >Minimum size is %1$s</string >
148149 <string name =" error_max_size" >Maximum size is %1$s</string >
149150</resources >
You can’t perform that action at this time.
0 commit comments