0

For functions with fixed number of parameters validations works fine, Eg:

@validate(validators= {'foo': bar })
def func(self, foo=None):
    pass

However I am facing difficulty to validate a function with unknown number of parameters, like for example

def func(*args, **kwargs):
    '''do something'''
    pass

Any idea what I should be doing?

1 Answers1

1

Do arguments have any rule? Like they are all of the same type repeated or things like that?

TurboGears2 actually accepts anything with a validate method as the validator. So you can use a Formencode Schema as validator http://turbogears.readthedocs.org/en/latest/turbogears/validation.html#schema-validation or you can roll your own class and raise a TGValidationError from it ( http://turbogears.readthedocs.org/en/latest/reference/classes.html#tg.validation.TGValidationError ).

amol
  • 1,609
  • 1
  • 10
  • 15