Extending protorpc StringField

145 Views Asked by At

I would like to write custom validation for some fields in ProtoRPC messages. The documentation says, that protorpc.messages.Field class cannot be extended by developers.

Does it mean I should not extend StringField?

E.g. StringField does not ensure that string is non-empty.

I've checked, and my custom string class with my validate_element method works as expected. Is there any reason, I should not do that?

1

There are 1 best solutions below

0
On

You can subclass protorpc.messages.MessageField to create a custom Field. See the DataTimeField source code for an example of this.