Example #1
0
})

schedules_validator = Validator({
    'number': [],
    'description': [required, length(min=5, max=512)],
    'start': [required],
    'finish': [required],
    'duration': [],
})

when_validator = Validator({
    'begin': [],
    'end': [],
    'total_duration': [],
    'schedules': schedules_validator
})

training_validator = Validator({
    'number': [],
    'recorded': [],
    'title': [required, length(min=5, max=512)],
    'description': [required, length(min=15, max=512)],
    'category': [required, one_of([item.name for item in CategoryType])],
    'operator': [required, {'organization': organization_validator}],
    'when': when_validator,
    'where': [],
    'participants': [],
    'costs': []

})
"""
"""

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)]
})
Example #3
0
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': [
        required,
        relative_date(
            min=timedelta(days=-80 * 365),
            max=timedelta(days=-7 * 365))
    ]
})