ContainsInvalidChars() public static method

Checks for unprintable or illegal characters in a message.
public static ContainsInvalidChars ( string message ) : bool
message string Message to check.
return bool
Esempio n. 1
0
 public static bool IsValidPrefix([NotNull] string prefix)
 {
     if (prefix == null)
     {
         throw new ArgumentNullException("prefix");
     }
     if (prefix.Length == 0)
     {
         return(true);
     }
     if (prefix.Length > 1)
     {
         return(false);
     }
     return(!Chat.ContainsInvalidChars(prefix));
 }
Esempio n. 2
0
        /// <summary> Checks whether given value is an acceptable rank prefix.
        /// Rank prefixes must be 0 or 1 character long, and contain only characters printable in Minecraft. </summary>
        /// <exception cref="ArgumentNullException"> If prefix is null. </exception>
        public static bool IsValidPrefix([NotNull] string prefix)
        {
            if (prefix == null)
            {
                throw new ArgumentNullException("prefix");
            }
            switch (prefix.Length)
            {
            case 0:
                return(true);

            case 1:
                return(!Chat.ContainsInvalidChars(prefix));

            default:
                return(false);
            }
        }
Esempio n. 3
0
 public override void Validate(string value)
 {
     base.Validate(value);
     if (MinLength != NoLengthRestriction && value.Length < MinLength)
     {
         throw new FormatException(String.Format("Value string is too short; expected at least {0} characters.",
                                                 MinLength));
     }
     if (MaxLength != NoLengthRestriction && value.Length > MaxLength)
     {
         throw new FormatException(String.Format("Value string too long; expected at most {0} characters.",
                                                 MaxLength));
     }
     if (RestrictedChars && Chat.ContainsInvalidChars(value))
     {
         throw new FormatException(String.Format("Value contains restricted characters."));
     }
     if (regex != null && !regex.IsMatch(value))
     {
         throw new FormatException(String.Format("Value does not match the expected format: /{0}/.",
                                                 RegexString));
     }
 }
Esempio n. 4
0
 public static bool IsValidPrefix( [NotNull] string prefix ) {
     if( prefix == null ) throw new ArgumentNullException( "prefix" );
     if( prefix.Length == 0 ) return true;
     if( prefix.Length > 1 ) return false;
     return !Chat.ContainsInvalidChars( prefix );
 }