5 module Puppet::Parser::Functions
6 newfunction(:is_email_address, :type => :rvalue, :doc => <<-EOS
7 Returns true if the string passed to this function is a valid email address.
10 if arguments.size != 1
11 raise(Puppet::ParseError, "is_email_address(): Wrong number of arguments given #{arguments.size} for 1")
14 # Taken from http://emailregex.com/ (simpler regex)
15 valid_email_regex = %r{\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z}
16 return (arguments[0] =~ valid_email_regex) == 0
20 # vim: set ts=2 sw=2 et :