Package muntjac :: Package data :: Package validators :: Module email_validator
[hide private]
[frames] | no frames]

Source Code for Module muntjac.data.validators.email_validator

 1  # Copyright (C) 2012 Vaadin Ltd.  
 2  # Copyright (C) 2012 Richard Lincoln 
 3  #  
 4  # Licensed under the Apache License, Version 2.0 (the "License");  
 5  # you may not use this file except in compliance with the License.  
 6  # You may obtain a copy of the License at  
 7  #  
 8  #     http://www.apache.org/licenses/LICENSE-2.0  
 9  #  
10  # Unless required by applicable law or agreed to in writing, software  
11  # distributed under the License is distributed on an "AS IS" BASIS,  
12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
13  # See the License for the specific language governing permissions and  
14  # limitations under the License. 
15   
16  """String validator for e-mail addresses.""" 
17   
18  from muntjac.data.validators.regexp_validator import RegexpValidator 
19   
20   
21 -class EmailValidator(RegexpValidator):
22 """String validator for e-mail addresses. The e-mail address syntax is not 23 complete according to RFC 822 but handles the vast majority of valid e-mail 24 addresses correctly. 25 26 See L{AbstractStringValidator} for more information. 27 28 @author: Vaadin Ltd. 29 @author: Richard Lincoln 30 @version: 1.1.2 31 """ 32
33 - def __init__(self, errorMessage):
34 """Creates a validator for checking that a string is a syntactically 35 valid e-mail address. 36 37 @param errorMessage: 38 the message to display in case the value does not validate. 39 """ 40 super(EmailValidator, self).__init__(('^([a-zA-Z0-9_\\.\\-+])+' 41 '@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$'), True, errorMessage)
42