Method: App42::Util#throwExceptionIfEmailNotValid
- Defined in:
- lib/util/util.rb
#throwExceptionIfEmailNotValid(obj, name) ⇒ Object
An exception to check whether the email entered is valid or not.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/util/util.rb', line 166 def throwExceptionIfEmailNotValid(obj, name) if(obj==nil) raise App42Exception.new(name +" parameter can not be null") end email_regex = %r{ ^ # Start of string [0-9a-z] # First character [0-9a-z.+]+ # Middle characters [0-9a-z] # Last character @ # Separating @ character [0-9a-z] # Domain name begin [0-9a-z.-]+ # Domain name middle [0-9a-z] # Domain name end $ # End of string }xi if (obj =~ email_regex) == 0 else raise App42Exception.new(name + " is not valid. ") end end |