1BSON_VALIDATE_WITH_ERROR(3)         libbson        BSON_VALIDATE_WITH_ERROR(3)
2
3
4

NAME

6       bson_validate_with_error - bson_validate_with_error()
7

SYNOPSIS

9          typedef enum {
10             BSON_VALIDATE_NONE = 0,
11             BSON_VALIDATE_UTF8 = (1 << 0),
12             BSON_VALIDATE_DOLLAR_KEYS = (1 << 1),
13             BSON_VALIDATE_DOT_KEYS = (1 << 2),
14             BSON_VALIDATE_UTF8_ALLOW_NULL = (1 << 3),
15             BSON_VALIDATE_EMPTY_KEYS = (1 << 4),
16          } bson_validate_flags_t;
17
18          bool
19          bson_validate_with_error (const bson_t *bson,
20                                    bson_validate_flags_t flags,
21                                    bson_error_t *error);
22

PARAMETERS

24bson: A bson_t.
25
26flags: A bitwise-or of all desired validation flags.
27
28error: Optional bson_error_t.
29

DESCRIPTION

31       Validates  a BSON document by walking through the document and inspect‐
32       ing the keys and values for valid content.
33
34       You can modify how the validation occurs through the use of  the  flags
35       parameter. A description of their effect is below.
36
37BSON_VALIDATE_NONE Basic validation of BSON length and structure.
38
39BSON_VALIDATE_UTF8 All keys and string values are checked for invalid
40         UTF-8.
41
42BSON_VALIDATE_UTF8_ALLOW_NULL String values are allowed to  have  em‐
43         bedded NULL bytes.
44
45BSON_VALIDATE_DOLLAR_KEYS  Prohibit keys that start with $ outside of
46         a "DBRef" subdocument.
47
48BSON_VALIDATE_DOT_KEYS Prohibit keys that contain . anywhere  in  the
49         string.
50
51BSON_VALIDATE_EMPTY_KEYS Prohibit zero-length keys.
52

RETURNS

54       Returns true if bson is valid; otherwise false and error is filled out.
55
56       The  bson_error_t  domain is set to BSON_ERROR_INVALID. Its code is set
57       to one of the bson_validate_flags_t flags indicating  which  validation
58       failed;  for example, if a key contains invalid UTF-8, then the code is
59       set to BSON_VALIDATE_UTF8, but if the basic structure of the BSON docu‐
60       ment  is corrupt, the code is set to BSON_VALIDATE_NONE. The error mes‐
61       sage is filled out, and gives more detail if possible.
62
63       SEE ALSO:
64          bson_validate().
65
66          bson_visitor_t can be used for custom validation, Example Custom Validation.
67
68

AUTHOR

70       MongoDB, Inc
71
73       2017-present, MongoDB, Inc
74
75
76
77
781.23.1                           Oct 20, 2022      BSON_VALIDATE_WITH_ERROR(3)
Impressum