How to use the formencode.validators.Email function in FormEncode

To help you get started, we’ve selected a few FormEncode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TurboGears / tg2 / tests / test_validation.py View on Github external
    @validate(validators={"a": validators.Int(), "someemail": validators.Email})
    def two_validators(self, a=None, someemail=None, *args):
        errors = pylons.tmpl_context.form_errors
        values =  pylons.tmpl_context.form_values
        return dict(a=a, someemail=someemail,
                errors=str(errors), values=str(values))
github apache / allura / ForgeTracker / forgetracker / widgets / admin.py View on Github external
def fields(self):
        fields = [
            ew.Checkbox(
                name='EnableVoting',
                label='Enable voting on tickets'),
            ew.Checkbox(
                name='AllowEmailPosting',
                label='Allow posting replies via email'),
            ew.TextField(
                name='TicketMonitoringEmail',
                label='Email ticket notifications to',
                validator=fev.Email(),
                grid_width='7'),
            ew.SingleSelectField(
                name='TicketMonitoringType',
                label='Send notifications for',
                grid_width='7',
                options=[
                    ew.Option(py_value='NewTicketsOnly',
                              label='New tickets only'),
                    ew.Option(py_value='NewPublicTicketsOnly',
                              label='New public tickets only'),
                    ew.Option(py_value='AllTicketChanges',
                              label='All ticket changes'),
                    ew.Option(py_value='AllPublicTicketChanges',
                              label='All public ticket changes'),
                ]),
            ffw.MarkdownEdit(
github ebroder / bluechips / bluechips / controllers / user.py View on Github external
from authkit.authorize.pylons_adaptors import authorize

from pylons import request
from pylons.decorators import validate
from pylons.decorators.secure import authenticate_form

from formencode import validators, Schema, FancyValidator, Invalid

log = logging.getLogger(__name__)


class EmailSchema(AuthFormSchema):
    "Validate email updates."
    allow_extra_fields = False
    new_email = validators.Email()


class UniqueUsername(FancyValidator):
    def _to_python(self, value, state):
        u = meta.Session.query(model.User).\
            filter(model.User.username == value).\
            first()
        if u:
            raise Invalid(
                'That username already exists',
                value, state)
        return value


class NewUserSchema(AuthFormSchema):
    "Validate new users."
github AppEnlight / appenlight / backend / src / appenlight / forms.py View on Github external
def email_validator(form, field):
    validator = formencode.validators.Email()
    try:
        validator.to_python(field.data)
    except formencode.Invalid as e:
        raise wtforms.ValidationError(e)
github apache / allura / ForgeDiscussion / forgediscussion / widgets / admin.py View on Github external
def fields(self):
        fields = [
            ew.HiddenField(name='app_id', label='App'),
            ew.TextField(name='name', label='Name',
                         validator=fev.UnicodeString()),
            ew.TextField(name='shortname', label='Short Name',
                         validator=All(
                             fev.Regex(ur"^[^\s\/\.]*$", not_empty=True, messages={
                                 'invalid': 'Shortname cannot contain space . or /',
                                 'empty': 'You must create a short name for the forum.'}),
                             UniqueForumShortnameValidator())),
            ew.TextField(name='parent', label='Parent Forum'),
            ew.TextField(name='description', label='Description',
                         validator=fev.UnicodeString()),
            ew.TextField(name='monitoring_email',
                         label='Monitoring Email', validator=fev.Email()),
            ew.Checkbox(name="members_only", label="Developer Only"),
            ew.Checkbox(name="anon_posts", label="Allow Anonymous Posts")
        ]
        return fields
github Othernet-Project / ndb-utils / ndb_utils / properties.py View on Github external
value = unicode(value)
        if not self.numeric_re.match(value):
            raise formencode.Invalid(self.message('not_a_number', state,
                                                  nan=value), value, state)

    def _validate_python(self, value, state):
        if value < self.min:
            raise formencode.Invalid(self.message('too_small', state),
                                     value, state)
        if value > self.max:
            raise formencode.Invalid(self.message('too_large', state),
                                     value, state)


slug_validator = formencode.validators.Regex(r'^[\w-]+$')
email_validator = formencode.validators.Email(strip=True)
decimal_validator = DecimalString()


class SlugProperty(ndb.StringProperty):
    """ Property that stores slugs """

    def _validate(self, value):
        if not value:
            return None
        try:
            return slug_validator.to_python(value)
        except formencode.api.Invalid, err:
            raise BadValueError(err)


class EmailProperty(ndb.StringProperty):
github Kotti / Kotti / kotti / views / login.py View on Github external
def _find_user(login):
    principals = get_principals()
    principal = principals.get(login)
    if principal is not None:
        return principal
    else:
        # noinspection PyBroadException
        try:
            Email().to_python(login)
        except Exception:
            pass
        else:
            for p in principals.search(email=login):
                return p
github the-virtual-brain / tvb-framework / tvb / interfaces / web / controllers / users_controller.py View on Github external
"""
    Validate Recover Password Form
    """
    email = validators.Email(not_empty=True)
    username = validators.String(not_empty=False)



class EditUserForm(formencode.Schema):
    """   
    Validate fields on user-edit
    """
    old_password = validators.UnicodeString(if_missing=None)
    password = validators.UnicodeString(if_missing=None)
    password2 = validators.UnicodeString(if_missing=None)
    email = validators.Email(if_missing=None)
    chained_validators = [validators.FieldsMatch('password', 'password2'),
                          validators.RequireIfPresent('password', present='old_password')]