.\" Man page generated from reStructuredText. . .TH "BSON_VALIDATE_WITH_ERROR" "3" "Jun 04, 2021" "1.17.6" "libbson" .SH NAME bson_validate_with_error \- bson_validate_with_error() . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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_flags_t; bool bson_validate_with_error (const bson_t *bson, bson_validate_flags_t flags, bson_error_t *error); .ft P .fi .UNINDENT .UNINDENT .SH PARAMETERS .INDENT 0.0 .IP \(bu 2 \fBbson\fP: A \fBbson_t\fP\&. .IP \(bu 2 \fBflags\fP: A bitwise\-or of all desired validation flags. .IP \(bu 2 \fBerror\fP: Optional \fBbson_error_t\fP\&. .UNINDENT .SH DESCRIPTION .sp Validates a BSON document by walking through the document and inspecting the keys and values for valid content. .sp You can modify how the validation occurs through the use of the \fBflags\fP parameter. A description of their effect is below. .INDENT 0.0 .IP \(bu 2 \fBBSON_VALIDATE_NONE\fP Basic validation of BSON length and structure. .IP \(bu 2 \fBBSON_VALIDATE_UTF8\fP All keys and string values are checked for invalid UTF\-8. .IP \(bu 2 \fBBSON_VALIDATE_UTF8_ALLOW_NULL\fP String values are allowed to have embedded NULL bytes. .IP \(bu 2 \fBBSON_VALIDATE_DOLLAR_KEYS\fP Prohibit keys that start with \fB$\fP outside of a "DBRef" subdocument. .IP \(bu 2 \fBBSON_VALIDATE_DOT_KEYS\fP Prohibit keys that contain \fB\&.\fP anywhere in the string. .IP \(bu 2 \fBBSON_VALIDATE_EMPTY_KEYS\fP Prohibit zero\-length keys. .UNINDENT .SH SEE ALSO .sp \fBbson_validate()\fP\&. .sp \fBbson_visitor_t\fP can be used for custom validation, example_custom_validation\&. .SH RETURNS .sp Returns true if \fBbson\fP is valid; otherwise false and \fBerror\fP is filled out. .sp The \fBbson_error_t\fP domain is set to \fBBSON_ERROR_INVALID\fP\&. Its code is set to one of the \fBbson_validate_flags_t\fP flags indicating which validation failed; for example, if a key contains invalid UTF\-8, then the code is set to \fBBSON_VALIDATE_UTF8\fP, but if the basic structure of the BSON document is corrupt, the code is set to \fBBSON_VALIDATE_NONE\fP\&. The error message is filled out, and gives more detail if possible. .SH AUTHOR MongoDB, Inc .SH COPYRIGHT 2017-present, MongoDB, Inc .\" Generated by docutils manpage writer. .