/usr/lib/python2.7/dist-packages/formalchemy/tests/test_validators.py is in python-formalchemy 1.4.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # -*- coding: utf-8 -*-
from formalchemy.tests import *
from formalchemy import validators
def validator1(value, field):
if not value:
raise ValidationError('Must have a value')
@validators.accepts_none
def validator2(value, field):
if not value:
raise ValidationError('Must have a value')
def accepts_none():
"""
>>> fs = FieldSet(bill)
>>> fs.configure(include=[fs.name.validate(validator1)])
>>> fs = fs.bind(data={'User-1-name':''})
>>> fs.validate()
True
>>> fs = FieldSet(bill)
>>> fs.configure(include=[fs.name.validate(validator2)])
>>> fs = fs.bind(data={'User-1-name':''})
>>> fs.validate()
False
"""
|