How to use the formencode.validators.String 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 apache / allura / ForgeTracker / forgetracker / widgets / admin.py View on Github external
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(
                name='TicketHelpNew',
                label='Help text to display on new ticket page',
                validator=fev.String(),
                attrs={'style': 'width: 95%'}),
            ffw.MarkdownEdit(
                name='TicketHelpSearch',
                label='Help text to display on ticket list pages (index page,'
                      ' search results, milestone lists)',
                validator=fev.String(),
                attrs={'style': 'width: 95%'}),
        ]
        return fields
github Pylons / shootout / shootout / views.py View on Github external
elif post_data.get('form.vote_miss'):
        idea.vote(voter, False)

    session.flush()

    return response


class RegistrationSchema(formencode.Schema):
    allow_extra_fields = True
    username = formencode.validators.PlainText(not_empty=True)
    password = formencode.validators.PlainText(not_empty=True)
    email = formencode.validators.Email(resolve_domain=False)
    name = formencode.validators.String(not_empty=True)
    password = formencode.validators.String(not_empty=True)
    confirm_password = formencode.validators.String(not_empty=True)
    chained_validators = [
        formencode.validators.FieldsMatch('password', 'confirm_password')
    ]


@view_config(permission='view', route_name='register',
             renderer='templates/user_add.pt')
def user_add(request):

    form = Form(request, schema=RegistrationSchema)

    if 'form.submitted' in request.POST and form.validate():
        session = DBSession()
        username = form.data['username']
        user = User(
            username=username,
github iovation / launchkey-python / launchkey / entities / validation.py View on Github external
class DirectoryGetDeviceResponseValidator(Schema):
    """Directory get Device response validator"""
    id = validators.String()
    name = validators.String()
    status = validators.Int()
    type = validators.String()
    allow_extra_fields = True


class DirectoryGetSessionsValidator(Schema):
    """Directory get Sessions validator"""
    auth_request = validators.String()
    date_created = ValidateISODate()
    service_icon = validators.String()
    service_id = validators.String()
    service_name = validators.String()
    allow_extra_fields = True


class DirectoryValidator(Schema):
    """Directory entity validator"""
    id = validators.String()
    service_ids = ForEach(validators.String())
    sdk_keys = ForEach(validators.String())
    premium = validators.Bool()
    name = validators.String()
    android_key = validators.String()
    ios_certificate_fingerprint = validators.String()
    active = validators.Bool()
    denial_context_inquiry_enabled = validators.Bool(if_empty=False,
                                                     if_missing=False)
github tony-landis / PonyExpress / ponyexpress / __init__.py View on Github external
from flask import Flask, session, redirect, url_for, request, render_template, jsonify
import core
import couch
import formencode
import gearman


class TemplateForm(formencode.Schema):
	"""
	Formencode Form validators for Email Template add/edit
	"""
	allow_extra_fields = True
	filter_exter_fields = True
	pre_validators = [formencode.variabledecode.NestedVariables()]
	_id = formencode.validators.String(not_empty=True, if_missing=None)
	name = formencode.validators.String(not_empty=True)
	class contents(formencode.Schema):
		lang = formencode.validators.String(not_empty=False)
		subject = formencode.validators.String(not_empty=False)
		body = formencode.validators.String(not_empty=False)
	contents = formencode.ForEach(contents)

app = Flask(__name__)

try:
	app.config.from_envvar('PONYEXPRESS_CFG')
except Exception, e:
	print e
	app.config.update(
		DEBUG=True,
		GEARMAN_SERVERS='localhost:4730',
		SMTP_STRING='localhost|25',
github iovation / launchkey-python / launchkey / entities / validation.py View on Github external
administrative_area = validators.String(if_missing=None)
    postal_code = validators.String(if_missing=None, if_empty=None)


class PolicyGeoCircleValidator(Schema):
    """Validates GeoCircle fences inside policies"""
    allow_extra_fields = True
    latitude = validators.Number(not_empty=True)
    longitude = validators.Number(not_empty=True)
    radius = validators.Number(not_empty=True)


class PolicyFenceValidator(Schema):
    """Validates fence objects in policies"""
    allow_extra_fields = True
    type = validators.String(not_empty=True)
    name = validators.String(if_missing=None, not_empty=True)

    @staticmethod
    def _validate_other(value, state):
        if "type" in value:
            if value["type"] == "TERRITORY":
                value.update(PolicyTerritoryValidator().to_python(
                    value, state))
            elif value["type"] == "GEO_CIRCLE":
                value.update(PolicyGeoCircleValidator().to_python(
                    value, state))
        return value


class ConditionalGeoFenceValidator(Schema):
    """Validates conditional geofence policies"""
github mozilla-services / socorro / webapp / socorro / lib / queryparams.py View on Github external
def __init__(self, validator=None, separator=','):
    self.separator = separator
    if validator:
      self.subvalidator = validator
    else:
      self.subvalidator = formencode.validators.String()
github iovation / launchkey-python / launchkey / entities / validation.py View on Github external
del value["fences"]
        return value


class ServiceSecurityPolicyValidator(PolicyBaseValidator):
    """Service Policy validator"""
    allow_extra_fields = True
    deny_rooted_jailbroken = validators.Bool(if_missing=None)
    deny_emulator_simulator = validators.Bool(if_missing=None)


class JWEAuthorizationResponsePackageValidator(Schema):
    """Authorization Response JWE payload entity validator"""
    service_pins = ForEach()
    auth_request = validators.String()  # UUID
    type = validators.String()
    reason = validators.String()
    denial_reason = validators.String(if_missing=None, if_empty=None)
    device_id = validators.String()
    auth_policy = AuthPolicyValidator(if_missing=None)
    auth_methods = ForEach(AuthMethodsValidator())
    allow_extra_fields = True


class AuthorizeValidator(Schema):
    """Authorize entity validator"""
    auth_request = validators.String(not_empty=True)
    push_package = validators.String(if_missing=None, not_empty=True)
    device_ids = ForEach(validators.String(), if_missing=None)
    allow_extra_fields = True
github hep-gc / repoman / server / repoman / repoman / model / form.py View on Github external
"""Use this class to determine the uniqueness of a group"""
    def _to_python(self, value, state):
        group_q = meta.Session.query(model.Group)
        if group_q.filter(model.Group.name==value).first():
            state = 'CONFLICT'
            raise formencode.Invalid('conflict', value, state)
        else:
            return value

class NewGroupForm(formencode.Schema):
    allow_extra_fields = True
    filter_extra_fields = True

    name = formencode.All(formencode.validators.String(not_empty=True),
                          UniqueGroup())
    users = formencode.validators.String(if_missing=None)


###################
#   I M A G E S   #
###################
def validate_new_image(params):
    schema = NewImageForm()
    try:
        result = schema.to_python(params)
    except formencode.validators.Invalid, error:
        for e,v in error.error_dict.iteritems():
            if e=='name' and v.state=='CONFLICT':
                abort(409, '409 Conflict')
            else:
                abort(400, '400 Bad Request - validate_new_image')
    else:
github renxing / quora-python / forms.py View on Github external
self._handler.finish(html)

    # post process hook
    def __after__(self):
        pass





class LoginForm(BaseForm):
    login = validators.String(not_empty=True,strip=True)
    password = validators.String(not_empty=True)

class RegisterForm(BaseForm):
    login = validators.String(not_empty=True,strip=True,min=4,max=20)
    email = validators.Email(not_empty=True,strip=True)
    name = validators.String(not_empty=True,strip=True)
    password = validators.String(not_empty=True)
    password_confirm = validators.String(not_empty=True)
    chained_validators = [validators.FieldsMatch('password', 'password_confirm')]

class SettingsForm(BaseForm):
    email = validators.Email(not_empty=True,strip=True)
    name = validators.String(not_empty=True,strip=True)
    blog = validators.URL(not_empty=True,strip=True)
    bio = validators.String(not_empty=True,max=300)
    
class AskForm(BaseForm):
    title = validators.String(not_empty=True,min=5,max=255,strip=True)
    body = validators.String()
    tags = validators.String(strip=True)