lib/ircsupport/validations.rb in ircsupport-0.1.0 vs lib/ircsupport/validations.rb in ircsupport-0.2.0

- old
+ new

@@ -8,26 +8,28 @@ \z /x # @private @@channel = /[^\x00\x07\x0a\x0d :,]+/ + module_function + + # Check if a string is a valid nickname. # @param [String] nickname A nickname to validate. # @return [Boolean] Will be true if the nickname is valid. def valid_nickname?(nickname) return true if nickname =~ @@nickname return false end + # Check if a string is a valid channel name. # @param [String] channel A channel name to validate. # @param [Array] chantypes The channel types which are allowed. This is # the same as the "CHANTYPES" isupport option. # @return [Boolean] Will be true if the channel name is valid. def valid_channel_name?(channel, chantypes = ['#', '&']) prefix = Regexp.quote(chantypes.join) return false if channel.bytesize > 200 return true if channel =~ /\A[#{prefix}]#@@channel\z/ return false end - - module_function :valid_nickname?, :valid_channel_name? end end