Last change
on this file since 30960 was 30960, checked in by davidb, 8 years ago |
Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster
|
File size:
620 bytes
|
Line | |
---|
1 | #
|
---|
2 | # is_email_address.rb
|
---|
3 | #
|
---|
4 |
|
---|
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.
|
---|
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
|
---|
19 | end
|
---|
20 |
|
---|
21 | # vim: set ts=2 sw=2 et :
|
---|
Note:
See
TracBrowser
for help on using the repository browser.