Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3740

Implement root and top level key utf-8 validation settings for BSON

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • bson-4.6.0
    • Affects Version/s: None
    • Component/s: BSON
    • Not Needed

      Description

      Implement a new validation option in `DeserializeOptions` that allows all or a specified subset of top-level keys in a document to be excluded from strict utf-8 validation and instead apply the replacement behavior.

      See design doc.

      Acceptance criteria

      • The new option should be called `validation` and accept an object with a `utf8` key that acts as follows:
        • `utf8: false` disables all utf-8 validation on any field or subfield in the document
        • `utf8: true` applies utf-8 validation to all fields in the document, and is the default setting
        • `utf8: { [key: string]: true }

          ` disables utf-8 validation for all fields except the ones specified (or their subfields)

        • `utf8: { [key: string]: false }

          ` disables utf-8 validation only for the specified fields (and their subfields)

        • When an object is specified as the `utf8` validation rule, an error should be thrown if `Object.values(validation.utf8)`
          • contains a mix of `true` and `false`
          • is empty
      • Tests should be added to ensure deserialization throws an error in all of the above cases when a non-excluded key contains invalid utf-8
      • Tests should be added to ensure deserialization produces a document with replacement characters in the invalid utf-8 locations when an excluded key contains invalid utf-8

            Assignee:
            grace.chong@mongodb.com Grace Chong (Inactive)
            Reporter:
            daria.pardue@mongodb.com Daria Pardue
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: