예제 #1
0
"""
"""

from wheezy.validation.rules import length
from wheezy.validation.rules import required


password_rules = [required, length(min=8), length(max=12)]
예제 #2
0
    """
    __slots__ = ('data_model_class', 'message_template')

    def __init__(self, data_model_class, message_template=None):
        self.data_model_class = data_model_class
        self.message_template = message_template or _(
            "Field's size exceeds its maximum value.")

    def __call__(self, message_template):
        """ Let you customize message template.
        """
        return AutoLengthRule(message_template)

    def validate(self, value, name, model, result, gettext):
        max_len = self.data_model_class.max_str_len(name)
        if max_len is not None and len(value) > max_len:
            result.append(gettext(self.message_template))
            return False
        return True


auto_length = AutoLengthRule

tournament_validator = Validator({
    'title': [required, auto_length(Tournament)],
    'description': [required, length(min=5),
                    auto_length(Tournament)],
    'organiser': [required, length(min=5),
                  auto_length(Tournament)],
})
예제 #3
0
"""
"""

from wheezy.validation import Validator
from wheezy.validation.rules import iterator
from wheezy.validation.rules import length
from wheezy.validation.rules import one_of
from wheezy.validation.rules import range
from wheezy.validation.rules import required


slug_rules = [required, length(min=2), length(max=35)]

search_posts_validator = Validator({
    'q': [length(max=20)],
    'page': [range(min=0), range(max=9)]
})

post_spec_validator = Validator({
    'slug': slug_rules,
    'fields': [iterator([one_of(('', 'permissions', 'comments'))])]
})

post_comment_validator = Validator({
    'slug': slug_rules,
    'message': [required, length(min=2), length(max=250)]
})
예제 #4
0
파일: upimage.py 프로젝트: mshibata/imgbbs
from wheezy.validation import Validator
from wheezy.validation.rules import length, required

upimage_validator = Validator({
    'author': [length(max=10)],
    'title': [length(max=20)],
    'message': [length(min=0, max=512)],
    'img': [required(message_template='<span class="red">画像が未選択です</span>')],
    'delkey': [length(max=20)],
})

reply_validator = Validator({
    'parent_id': [required(message_template='<span class="red">返信先IDがありません</span>')],
    'author': [length(max=10)],
    'message': [length(min=3, max=512), required(message_template='<span class="red">メッセージ内容を3文字以上入れてください</span>')],
#    'img': [required(message_template='<span class="red">画像が未選択です</span>')],
    'delkey': [length(max=20)],
})

delete_validator = Validator({
    'id': [required(message_template='<span class="red">削除対象となるIDがありません</span>')],
    'delkey': [required(message_template='<span class="red">削除キーを指定してください</span>')],
})


예제 #5
0
"""
"""

from wheezy.validation import Validator
from wheezy.validation.rules import compare
from wheezy.validation.rules import email
from wheezy.validation.rules import length
from wheezy.validation.rules import required

from membership.rules import password_rules


credential_validator = Validator({
    'username': [required, length(min=2), length(max=20)],
    'password': password_rules
})

password_match_validator = Validator({
    'password': [
        compare(
            equal='confirm_password',
            message_template='Passwords do not match.')
    ]
})

signup_validator = Validator({
    'email': [required, length(min=6), length(max=30), email],
    # 'first_name': [required, length(max=30)],
    # 'last_name': [required, length(max=30)]
})
예제 #6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2015 blackshirt


__author__ = 'simbah'

from wheezy.validation import Validator
from wheezy.validation.rules import required, length, one_of

from models import CategoryType

personal_validator = Validator({
    'number': [],
    'name': [required, length(min=5, max=512)],
    'nip': [required],
    'group': [required],
    'position': [required],
    'unit_wkplaces': [],
    'main_wkplaces': [required],
})

organization_validator = Validator({
    'number': [],
    'name': [required, length(min=5, max=512)],
    'address': [required, length(min=5, max=512)],
    'city': [required, length(min=5, max=512)],
    'phone': [],
    'email': [],
    'fax': [],
예제 #7
0
""" ``validation`` module.
"""

from wheezy.validation import Validator
from wheezy.validation.rules import length
from wheezy.validation.rules import required


greeting_validator = Validator({
    'author': [length(max=20)],
    'message': [required, length(min=5, max=512)],
})
예제 #8
0
from wheezy.validation import Validator
from wheezy.validation.rules import compare
from wheezy.validation.rules import email
from wheezy.validation.rules import length
from wheezy.validation.rules import one_of
from wheezy.validation.rules import relative_date
from wheezy.validation.rules import required

from membership.rules import identity
from membership.rules import password_rules


_ = lambda s: s

credential_validator = Validator({
    'username': [required, length(min=2), length(max=20)],
    'password': password_rules
})

account_validator = Validator({
    'email': [required, length(min=6), length(max=30), email],
    'display_name': [required, length(max=30)],
    'account_type': [required, one_of(('user', 'business'))]
})

registration_validator = Validator({
    'credential': credential_validator,
    'account': account_validator,
    'answer': [required, length(min=1, max=20)],
    'question_id': [required, identity(max=3)],
    'date_of_birth': [