mixxorz / django-service-objects

Service objects for Django
MIT License
337 stars 29 forks source link

Allow for required is false #36

Closed joeydebreuk closed 6 years ago

joeydebreuk commented 6 years ago

I suggest support for Field(required=False) is added to service_objects fields. I would like to be able to do something like this.

class ServiceExample(Service):
    some_model = ModelField(model_class='SomeModel', required=False)

    def process(self):
        some_model = self.cleaned_data['some_model']
        if some_model:
            'do a'
        else:
            'do b'

I would say updating docs is not needed since is expected behavior of a field - but maybe a small mention wouldn't hurt.

Please let me know what you think.

c17r commented 6 years ago

You removed the error and the list check from MultipleFormField which it needs to be there. Need to rollback the last commit. The line you need to remove is around line 87 in ModelField

joeydebreuk commented 6 years ago

Cleaned up the commits. All should be good now.

c17r commented 6 years ago

merged, thanks!