emmett-framework / emmett

The web framework for inventors
BSD 3-Clause "New" or "Revised" License
1.06k stars 71 forks source link

Allow to mix custom validators with standard syntax #158

Closed gi0baro closed 7 years ago

gi0baro commented 8 years ago

eg:

validation = {
    'field_name': {'is': 'int', 'custom': my_method}
}
Marlysson commented 7 years ago

What is need to this task are done? I want contribute.

gi0baro commented 7 years ago

@Marlysson add the parsing and addition of the custom validator here: https://github.com/gi0baro/weppy/blob/master/weppy/validators/__init__.py#L104

Mind that probably this should probably inserted before the allow parsing, see line https://github.com/gi0baro/weppy/blob/master/weppy/validators/__init__.py#L244 or the order will probably break.

Marlysson commented 7 years ago

@gi0baro excellent .. I will see and analysing the weppy source code and your workflow .. some doubts I will come back here..

gi0baro commented 7 years ago

@Marlysson sure, thank you!

Marlysson commented 7 years ago

@gi0baro This feature looks like this?

http://weppy.org/docs/0.8/validations

Section Custom Validator

gi0baro commented 7 years ago

@Marlysson yep, see the description

Marlysson commented 7 years ago

Then this already are done?

gi0baro commented 7 years ago

@Marlysson nope. Right now you can use the weppy validation language (eg: {'is': 'int', 'gte': 0, 'lt': 6}) or a custom validator of your own.

The issue is to use both of them, as reported in the description. So the validation parser (https://github.com/gi0baro/weppy/blob/master/weppy/validators/__init__.py#L104#L250) should be updated to add a validator specified with the 'custom' key into the final list of operations.