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

24       · bson: A bson_t.
25
26       · flags: A bitwise-or of all desired validation flags.
27
28       · error: 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
37       · BSON_VALIDATE_NONE Basic validation of BSON length and structure.
38
39       · BSON_VALIDATE_UTF8 All keys and string values are checked for invalid
40         UTF-8.
41
42       · BSON_VALIDATE_UTF8_ALLOW_NULL  String  values  are  allowed  to  have
43         embedded NULL bytes.
44
45       · BSON_VALIDATE_DOLLAR_KEYS  Prohibit keys that start with $ outside of
46         a "DBRef" subdocument.
47
48       · BSON_VALIDATE_DOT_KEYS Prohibit keys that contain . anywhere  in  the
49         string.
50
51       · BSON_VALIDATE_EMPTY_KEYS Prohibit zero-length keys.
52

SEE ALSO

54       bson_validate().
55
56       bson_visitor_t  can be used for custom validation, example_custom_vali‐
57       dation.
58

RETURNS

60       Returns true if bson is valid; otherwise false and error is filled out.
61
62       The bson_error_t domain is set to BSON_ERROR_INVALID. Its code  is  set
63       to  one  of the bson_validate_flags_t flags indicating which validation
64       failed; for example, if a key contains invalid UTF-8, then the code  is
65       set to BSON_VALIDATE_UTF8, but if the basic structure of the BSON docu‐
66       ment is corrupt, the code is set to BSON_VALIDATE_NONE. The error  mes‐
67       sage is filled out, and gives more detail if possible.
68

AUTHOR

70       MongoDB, Inc
71
73       2017-present, MongoDB, Inc
74
75
76
77
781.17.4                           Feb 04, 2021      BSON_VALIDATE_WITH_ERROR(3)
Impressum