Added django style choices
This commit is contained in:
parent
ef15733efe
commit
e1282028a5
@ -100,9 +100,9 @@ class BaseField(object):
|
||||
def _validate(self, value):
|
||||
# check choices
|
||||
if self.choices is not None:
|
||||
if value not in self.choices:
|
||||
raise ValidationError("Value must be one of %s."
|
||||
% unicode(self.choices))
|
||||
option_keys = [option_key for option_key, option_value in self.choices]
|
||||
if value not in option_keys:
|
||||
raise ValidationError("Value must be one of %s." % unicode(option_keys))
|
||||
|
||||
# check validation argument
|
||||
if self.validation is not None:
|
||||
|
@ -12,7 +12,6 @@ import datetime
|
||||
import decimal
|
||||
import gridfs
|
||||
import warnings
|
||||
import types
|
||||
|
||||
|
||||
__all__ = ['StringField', 'IntField', 'FloatField', 'BooleanField',
|
||||
|
Loading…
x
Reference in New Issue
Block a user