BSON_VALIDATE_WITH_ERROR(3)

πŸ’… BSON_VALIDATE_WITH_ERROR(3) β€” the libbson validation vibe check πŸ’…

okay bestie, welcome to the libbson manual page for bson_validate_with_error(3). this is the function that gives a BSON document a full vibe check and tells you what's off. no cap. ✨

✨ SYNOPSIS ✨

bool
bson_validate_with_error (const bson_t *bson,
                          bson_validate_flags_t flags,
                          bson_error_t *error);

πŸŽ€ PARAMETERS πŸŽ€

  • bson β€” a bson_t. the document getting its little inspection. πŸ¦‹
  • flags β€” a bitwise-or of all desired bson_validate_flags_t. mix and match the checks you want. πŸ’…
  • error β€” optional bson_error_t. bring it if you want the details later. 🫢

πŸ¦‹ DESCRIPTION πŸ¦‹

So this function validates a BSON document by walking through the document and inspecting the keys and values for valid content. like, it's doing a whole tour of every key and value, checking that everything is valid. periodt. πŸ‘‘

You can modify how the validation occurs through the use of the flags parameter β€” see bson_validate_flags_t for details. 🌸

🌈 RETURNS 🌈

If bson passes the requested validations, returns true. slay. Otherwise, returns false, and if error is non-NULL it will be filled out with details. 🫢

The bson_error_t domain is set to BSON_ERROR_INVALID. Its code is set to one of the bson_validate_flags_t flags indicating which validation failed; for example, if a key contains invalid UTF-8, then the code is set to BSON_VALIDATE_UTF8, but if the basic structure of the BSON document is corrupt, the code is set to BSON_VALIDATE_NONE. The error message is filled out, and gives more detail if possible. πŸ’€

To get the specific location of the error, use bson_validate_with_error_and_offset() instead. iykyk. πŸ“

πŸ‘€ SEE ALSO πŸ‘€

  • bson_validate(), bson_validate_with_error_and_offset().
  • bson_visitor_t can be used for custom validation, Example Custom Validation. 🧚

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc

2009-present, MongoDB, Inc.


πŸ“ that's the whole page, bestie! this is libbson version 2.5.6, dated Oct 09, 2026 β€” BSON_VALIDATE_WITH_ERROR(3) signing off. stay iconic and may all your BSON pass validation πŸ’–βœ¨
πŸ“¦ where this page comes from