"""
    wtforms.validators
    ~~~~~~~~~~~~~~~~~~
    
    TODO
    
    :copyright: 2007-2008 by James Crasta, Thomas Johansson.
    :license: MIT, see LICENSE.txt for details.
"""
import re

class ValidationError(ValueError):
    pass

def email(message=u'Invalid email address.'):
    def _email(form, field):
        if not re.match(r'^.+@[^.].*\.[a-z]{2,4}$', field.data, re.IGNORECASE):
            raise ValidationError(message)
    return _email

def equal_to(fieldname, message=u'Must be equal to %s'):
    def _equal_to(form, field):
        other = getattr(form, fieldname, None)
        if not other:
            raise ValidationError(u"Invalid field name '%s'" % fieldname)
        elif field.data != other.data:
            raise ValidationError(message % fieldname)
    return _equal_to

def ip_address(message=u'Invalid IP address.'):
    def _ip_address(form, field):
        if not re.match(r'^([0-9]{1,3}\.){3}[0-9]{1,3}$', field.data):
            raise ValidationError(message)
    return _ip_address

def is_checked(message=u'Field must tbe checked.'):
    def _is_checked(form, field):
        if not field.data:
            raise ValidationError(message)
    return _is_checked

def length(min=-1, max=-1, message=u'Field must be between %(min)i and %(max)i characters long.'):
    fmt_args = {'min': min, 'max': max}
    def _length(form, field):
        l = field.data and len(field.data) or 0
        if l < min or max != -1 and l > max:
            raise ValidationError(message % fmt_args)
    return _length

def not_empty(message=u'Field must not be empty.'):
    def _not_empty(form, field):
        if not field.data or not field.data.strip():
            raise ValidationError(message)
    return _not_empty

def url(allow_blank=False, message=u'Invalid URL.'):
    def _url(form, field):
        if allow_blank and not field.data:
            return
        if not re.match(r'[a-z]+://.*\.[a-z]{2,4}(\/.*)?', field.data, re.I):
            raise ValidationError(message)
    return _url

__all__ = ('ValidationError', 'email', 'equal_to', 'ip_address', 'is_checked', 'length', 'not_empty', 'url')

@@ -484,11 +484,62 @@
 age=
-u'M
+None):%0A    if not message:%0A        message = u'Field m
 ust 
@@ -553,18 +553,28 @@
 l to %25s'
-):
+ %25 fieldname
 %0A    def
@@ -821,28 +821,16 @@
 (message
- %25 fieldname
 )%0A    re
@@ -1272,32 +1272,77 @@
 max=-1, message=
+None):%0A    if not message:%0A        message = 
 u'Field must be 
@@ -1354,25 +1354,15 @@
 en %25
-(min)
 i and %25
-(max)
 i ch
@@ -1380,50 +1380,21 @@
 ng.'
-):%0A    fmt_args = %7B'min': 
+ %25 (
 min, 
-'
 max
-': max%7D
+)
 %0A   
@@ -1513,16 +1513,16 @@
  %3E max:%0A
+
         
@@ -1558,19 +1558,8 @@
 sage
- %25 fmt_args
 )%0A  

Remove use of substitution in standard validators. It forced usage of the values with custom messages.