Skip to content

Commit 4dbddbf

Browse files
chrisbobbegnprice
authored andcommitted
RealmInputScreen: Add ValidationError.Empty
1 parent 49b70c0 commit 4dbddbf

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/start/RealmInputScreen.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ type Props = $ReadOnly<{|
2525
|}>;
2626

2727
enum ValidationError {
28-
InvalidUrl = 0,
29-
NoUseEmail = 1,
28+
Empty = 0,
29+
InvalidUrl = 1,
30+
NoUseEmail = 2,
3031
}
3132

3233
function validationErrorMsg(validationError: ValidationError): LocalizableText {
3334
switch (validationError) {
35+
case ValidationError.Empty:
36+
return 'Please enter a URL.';
3437
case ValidationError.InvalidUrl:
3538
return 'Please enter a valid URL.';
3639
case ValidationError.NoUseEmail:
@@ -45,6 +48,10 @@ type MaybeParsedInput =
4548
const tryParseInput = (realmInputValue: string): MaybeParsedInput => {
4649
const trimmedInputValue = realmInputValue.trim();
4750

51+
if (trimmedInputValue.length === 0) {
52+
return { valid: false, error: ValidationError.Empty };
53+
}
54+
4855
const withScheme = /^https?:\/\//.test(trimmedInputValue)
4956
? trimmedInputValue
5057
: `https://${trimmedInputValue}`;

static/translations/messages_en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"Chat": "Chat",
130130
"Sign in with {method}": "Sign in with {method}",
131131
"Invalid input": "Invalid input",
132+
"Please enter a URL.": "Please enter a URL.",
132133
"Please enter a valid URL.": "Please enter a valid URL.",
133134
"Please enter the server URL, not your email.": "Please enter the server URL, not your email.",
134135
"Wrong email or password. Try again.": "Wrong email or password. Try again.",

0 commit comments

Comments
 (0)