这是indexloc提供的服务,不要输入任何密码
Skip to content

handle collection validators with object fields that do not list properties #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

hallettj
Copy link
Collaborator

If a collection validator species an property of type object, but does not specify a list of nested properties for that object then we will infer the ExtendedJSON type for that property. For a collection created with this set of options would have the type ExtendedJSON for its reactions field:

{
  "validator": {
    "$jsonSchema": {
      "bsonType": "object",
      "properties": {
        "reactions": { "bsonType": "object" },
      }
    }
  }
}

If the validator specifies a map of nested properties, but that map is empty, then we interpret that as an empty object type.

Copy link
Contributor

@daniel-chambers daniel-chambers left a comment

Choose a reason for hiding this comment

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

LGTM, other than the failing tests...

Comment on lines 153 to 155
Property::Object {
properties: None, ..
} => (vec![], Type::ExtendedJSON),
Copy link
Contributor

Choose a reason for hiding this comment

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

The meat of the change.

@hallettj hallettj merged commit 37831c6 into main Jan 17, 2025
1 check passed
@hallettj hallettj deleted the jessehallett/eng-1509-mongodb-handle-validator-with-object-field-with-no branch January 17, 2025 20:35
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.

2 participants