---
name: "bson_validate_flags_t"
section: "3"
platform: "linux"
package: "libbson-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bson_validate_flags_t"
---

# bson\_validate\_flags\_t(3)

Document validation options

## SYNOPSIS

```
#include <bson/bson-types.h>
typedef enum {
  BSON_VALIDATE_NONE = 0,
  BSON_VALIDATE_UTF8 = (1 << 0),
  BSON_VALIDATE_DOLLAR_KEYS = (1 << 1),
  BSON_VALIDATE_DOT_KEYS = (1 << 2),
  BSON_VALIDATE_UTF8_ALLOW_NULL = (1 << 3),
  BSON_VALIDATE_EMPTY_KEYS = (1 << 4),
  BSON_VALIDATE_CORRUPT = (1 << 5),
} bson_validate_flags_t;
```

## DESCRIPTION

**bson\_validate\_flags\_t** is a set of binary flags which may be combined to specify a level of BSON document validation.

A value of **0**, **false**, or **BSON\_VALIDATE\_NONE** equivalently requests the minimum applicable level of validation.

In the context of validation APIs *bson\_validate()*, *bson\_validate\_with\_error()*, and *bson\_validate\_with\_error\_and\_offset()* the minimum validation still guarantees that a document can be successfully traversed by *bson\_iter\_visit\_all()*.

Higher level APIs using this type may have different minimum validation levels. For example, **libmongoc** functions that take **bson\_validate\_flags\_t** use **0** to mean the document contents are not visited and malformed headers will not be detected by the client.

Each defined flag aside from **BSON\_VALIDATE\_NONE** describes an optional validation feature that may be enabled, alone or in combination with other features:

- •

  **BSON\_VALIDATE\_NONE** Minimum level of validation; in **libbson**, validates element headers.

- •

  **BSON\_VALIDATE\_UTF8** All keys and string values are checked for invalid UTF-8.

- •

  **BSON\_VALIDATE\_UTF8\_ALLOW\_NULL** String values are allowed to have embedded NULL bytes.

- •

  **BSON\_VALIDATE\_DOLLAR\_KEYS** Prohibit keys that start with **$** outside of a "DBRef" subdocument.

- •

  **BSON\_VALIDATE\_DOT\_KEYS** Prohibit keys that contain **.** anywhere in the string.

- •

  **BSON\_VALIDATE\_EMPTY\_KEYS** Prohibit zero-length keys.

- •

  **BSON\_VALIDATE\_CORRUPT** is not a control flag, but is used as an error code when a validation routine encounters corrupt BSON data.

**SEE ALSO:**

```
bson_validate(), bson_validate_with_error(), bson_validate_with_error_and_offset().
```

```
bson_visitor_t can be used for custom validation, Example Custom Validation.
```

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
