cleaning and refactoring chat system
and also fixing chat inputs validation.
This commit is contained in:
parent
4b66a9fd06
commit
137b4a3abf
8 changed files with 167 additions and 165 deletions
|
|
@ -36,14 +36,20 @@ namespace Yavsc
|
|||
}
|
||||
public bool ValidateUserName (string userName)
|
||||
{
|
||||
bool valid = ValidateStringLength(userName, 1,12);
|
||||
if (valid) valid = IsLetterOrDigit(userName);
|
||||
NotifyUser(NotificationTypes.Error, "char:"+userName.First (c => !char.IsLetterOrDigit(c)), ChatHub.InvalidUserName);
|
||||
bool valid = true;
|
||||
|
||||
if (userName.Length<1 || userName[0] == '?' && userName.Length<2) valid = false;
|
||||
if (valid) {
|
||||
string suname = (userName[0] == '?') ? userName.Substring(1) : userName;
|
||||
if (valid) valid = ValidateStringLength(suname, 1,12);
|
||||
if (valid) valid = IsLetterOrDigit(userName);
|
||||
}
|
||||
if (!valid) NotifyUser(NotificationTypes.Error, "userName" , ChatHub.InvalidUserName);
|
||||
return valid;
|
||||
}
|
||||
public bool ValidateMessage (string message)
|
||||
{
|
||||
if (!ValidateStringLength(message, 1,240))
|
||||
if (!ValidateStringLength(message, 1, 10240))
|
||||
{
|
||||
NotifyUser(NotificationTypes.Error, "message", ChatHub.InvalidMessage);
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue