mikeywaites / kim

Kim: A JSON Serialization and Marshaling framework
http://kim.readthedocs.org/en/latest/
Other
317 stars 17 forks source link

replace @hooks api with new FieldOpts options. #95

Closed mikeywaites closed 7 years ago

mikeywaites commented 8 years ago

Whilst it was a nice idea in practice it's pretty awful to use and generally leads to lots of code duplication. That coupled with the horror of self not being set when the method is called.

I think it would generally be a lit nicer to provide Field definitions with extra_inputs extra_validators extra_processors extra_outputs

An example definition would be something like.

@pipe
def my_validator(session):
    #do some stuff ...

class FooMapper(Mapper):
    id = field.Integer(extra_validators=[my_validator])

I think this will lead to a much cleaner, more predictable API all round.