Skip to content

When an object is already created, and is not replacing, skip all required fields that were not modified.#347

Open
Bernie wants to merge 1 commit into
Scille:mainfrom
Bernie:Fix_required_validation_on_partial_documents
Open

When an object is already created, and is not replacing, skip all required fields that were not modified.#347
Bernie wants to merge 1 commit into
Scille:mainfrom
Bernie:Fix_required_validation_on_partial_documents

Conversation

@Bernie

@Bernie Bernie commented Apr 17, 2021

Copy link
Copy Markdown

This fixes the issue reported in #346

@lafrech lafrech left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I agree on the cause.

Would it be a better implementation if we did this?

class EmbeddedDocument:
    def required_validate(self):
        self._data.required_validate(partial=self.is_created)

class DataProxy:
    def required_validate(self, partial):
        [...]
        if partial and name not in self.get_modified_fields():
            [...]

This avoids accessing _data.get_modified_fields from upper layers.

No need to even modify each driver.

Or maybe

class EmbeddedDocument:
    def required_validate(self, update=False):
        self._data.required_validate(update=update)

class DataProxy:
    def required_validate(self, update):
        [...]
        if update and name not in self.get_modified_fields():
            [...]

Needs to specify update explicitly in the drivers but might be better.

@Bernie

Bernie commented Apr 30, 2021 via email

Copy link
Copy Markdown
Author

@Neustradamus

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants