private static String checkUsername ( String username ) { if ( username . length ( ) < 3 ) { return "too short (minimum: 3 characters)" ; } else if ( username . length ( ) > 64 ) { return "too long (maximum: 64 characters)" ; } for ( int i = 0 ; i < username . length ( ) ; i ++ ) { char c = username . charAt ( i ) ; if ( c >= ' ' && c <= ' ' ) continue ; if ( c >= ' ' && c <= ' ' ) continue ; if ( c >= ' ' && c <= ' ' ) continue ; if ( c == ' ' ) continue ; return "invalid character at position " + ( i + 1 ) + ": " + jq ( "" + c ) ; } return null ; }
Returns null if the username is ok .