~unifield-team/unifield-web/uf-2235

« back to all changes in this revision

Viewing changes to addons/openerp/validators/validators.py

  • Committer: ame (Tiny)
  • Date: 2010-01-07 07:47:47 UTC
  • Revision ID: ame@tinyerp.com-20100107074747-sqc1cmm24gofqmuh
[REF] separating base API to openobject
[REF] removed all openerp related stuffs from base api

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#
28
28
###############################################################################
29
29
 
30
 
"""
31
 
This module defines validators.
32
 
"""
33
30
import re
34
31
import cgi
35
32
import math
38
35
import locale
39
36
 
40
37
from openobject.i18n import format
41
 
 
42
 
from formencode.validators import *
43
 
from formencode.schema import Schema
44
 
from formencode.foreach import ForEach
45
 
 
46
 
 
47
 
class BaseValidator(FancyValidator):
48
 
    pass
49
 
 
50
 
 
51
 
class DefaultValidator(BaseValidator):
52
 
    pass
53
 
 
54
 
 
55
 
class Schema(Schema):
56
 
    """Modified Schema validator.
57
 
 
58
 
    A schema validates a dictionary of values, applying different validators
59
 
    (by key) to the different values.
60
 
 
61
 
    This modified Schema allows fields that do not appear in the fields
62
 
    parameter of your schema, but filters them out from the value dictionary.
63
 
    You might want to set filter_extra_fields to True when you're building a
64
 
    dynamic form with unpredictable keys and need these values.
65
 
 
66
 
    """
67
 
 
68
 
    filter_extra_fields = True
69
 
    allow_extra_fields = True
70
 
    if_key_missing = None
71
 
 
72
 
    def from_python(self, value, state=None):
73
 
        # The Schema shouldn't do any from_python conversion because
74
 
        # adjust_value already takes care of that for all childs.
75
 
        return value
76
 
 
 
38
from openobject.validators import *
77
39
 
78
40
class String(BaseValidator):
79
41
    if_empty = False