Skip to content
Danila Ganchar edited this page Aug 9, 2024 · 3 revisions

v2 to v3 changes

# v2
class AbstractRule(object):
    def validate(self, value):
        """
        :return: only errors
        :rtype: list
        """
        raise NotImplementedError()


# v3
class AbstractRule(object):
    def validate(self, value):
        """
        :return: tuple of value and errors
        :rtype: tupple
        """
        raise NotImplementedError()

In v3 we can use **kwargs:

email_rules = CompositeRule(IsEmail(), MinLength(10), MaxLength(20))
params = [
    Param('email', GET, str, rules=email_rules),
    Param('streets', GET, list),
    Param('meta', GET, dict),
)

# v2
@app.route('/person')
@validate_params(*params)
def route_one(email, streets, meta):
    pass

# v3
@app.route('/person')
@validate_params(*params)
def route_one(**kwargs):
    print(kwargs)

See commit

Clone this wiki locally