SYNOPSIS
#include <bson.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_flags_t; bool bson_validate (const bson_t *bson, bson_validate_flags_t flags, size_t *offset);
DESCRIPTION
The bson_validate() function shall validate the contents of a bson document.
The aggressiveness of the validation is based on flags. You may bitwise-or the flags together for multiple checks.
BSON_VALIDATE_NONE: Only basic validate occurs.
BSON_VALIDATE_UTF8: Check that strings are valid UTF-8.
BSON_VALIDATE_DOLLAR_KEYS: Check that keys do not start with $.
BSON_VALIDATE_DOT_KEYS: Check that keys do not contain a period.
BSON_VALIDATE_UTF8_ALLOW_NULL: Allow NUL bytes in UTF-8 text.
RETURN VALUE
TRUE if bson is valid. Otherwise FALSE and offset is set.
ERRORS
If offset is non-NULL, it will be set to the offset in bytes of where the validation failed.
AUTHORS
This page was written by MongoDB, Inc.