source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 7 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

File size: 620 bytes
Line 
1#
2# is_email_address.rb
3#
4
5module Puppet::Parser::Functions
6 newfunction(:is_email_address, :type => :rvalue, :doc => <<-EOS
7Returns true if the string passed to this function is a valid email address.
8 EOS
9 ) do |arguments|
10 if arguments.size != 1
11 raise(Puppet::ParseError, 'is_email_address(): Wrong number of arguments '\
12 "given #{arguments.size} for 1")
13 end
14
15 # Taken from http://emailregex.com/ (simpler regex)
16 valid_email_regex = %r{\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z}
17 return (arguments[0] =~ valid_email_regex) == 0
18 end
19end
20
21# vim: set ts=2 sw=2 et :
Note: See TracBrowser for help on using the repository browser.