feat(auth): add input validation error handling
This commit is contained in:
parent
deb590ccb3
commit
c5308a7dff
1 changed files with 18 additions and 4 deletions
|
|
@ -60,15 +60,29 @@ namespace _Hub.Scripts.UI
|
||||||
(_maxUsernameLength >= _username.Length && _maxPasswordLength >= _password.Length) &&
|
(_maxUsernameLength >= _username.Length && _maxPasswordLength >= _password.Length) &&
|
||||||
usernameRegex.Success);
|
usernameRegex.Success);
|
||||||
EnableLoginButton(interactable);
|
EnableLoginButton(interactable);
|
||||||
|
|
||||||
|
UpdateInputErrors(usernameRegex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateInputErrors(Match usernameRegex)
|
||||||
|
{
|
||||||
//Username
|
//Username
|
||||||
if (_username != null)
|
if (string.IsNullOrEmpty(_username))
|
||||||
|
{
|
||||||
|
usernameInputField.Error(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var usernameTooLong = _username.Length > _maxUsernameLength;
|
var usernameTooLong = _username.Length > _maxUsernameLength;
|
||||||
usernameInputField.Error(usernameTooLong);
|
usernameInputField.Error(usernameTooLong || !usernameRegex.Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Password
|
//Password
|
||||||
if (_password != null )
|
if (string.IsNullOrEmpty(_password))
|
||||||
|
{
|
||||||
|
usernameInputField.Error(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var passwordTooLong = _password.Length > _maxPasswordLength;
|
var passwordTooLong = _password.Length > _maxPasswordLength;
|
||||||
passwordInputField.Error(passwordTooLong);
|
passwordInputField.Error(passwordTooLong);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue