def _validate(self):
dict = {
'validator' : None,
'min' : None,
'max' : None,
'minstrict' : 1,
'maxstrict' : 1,
}
opt = self['validate']
if type(opt) is types.DictionaryType:
dict.update(opt)
else:
dict['validator'] = opt
# Look up validator maps and replace 'validator' field with
# the corresponding function.
validator = dict['validator']
valFunction = self._getValidatorFunc(validator, 0)
self._checkValidateFunction(valFunction, 'validate', validator)
dict['validator'] = valFunction
# Look up validator maps and replace 'stringtovalue' field
# with the corresponding function.
if dict.has_key('stringtovalue'):
stringtovalue = dict['stringtovalue']
strFunction = self._getValidatorFunc(stringtovalue, 1)
self._checkValidateFunction(
strFunction, 'stringtovalue', stringtovalue)
else:
strFunction = self._getValidatorFunc(validator, 1)
if strFunction == validator:
strFunction = len
dict['stringtovalue'] = strFunction
self._validationInfo = dict
args = dict.copy()
del args['validator']
del args['min']
del args['max']
del args['minstrict']
del args['maxstrict']
del args['stringtovalue']
self._validationArgs = args
self._previousText = None
if type(dict['min']) == types.StringType and strFunction is not None:
dict['min'] = apply(strFunction, (dict['min'],), args)
if type(dict['max']) == types.StringType and strFunction is not None:
dict['max'] = apply(strFunction, (dict['max'],), args)
self._checkValidity()
评论列表
文章目录