{"record":{"id":"96efeaeab4f6b516","repo":"mongodb/mongoid","slug":"validation-of-document-failed","errorCode":null,"errorMessage":"Validation of %{document} failed.","messagePattern":"Validation of %(.+?) failed\\.","errorType":"validation","errorClass":"Mongoid::Errors::Validations","httpStatus":422,"severity":"error","filePath":"lib/mongoid/persistable.rb","lineNumber":130,"sourceCode":"      _mongoid_reset_atomic_context_changes! if has_own_context\n      raise e\n    ensure\n      _mongoid_pop_atomic_context if has_own_context\n\n      if call_depth.zero?\n        @atomic_depth = nil\n        @atomic_updates_to_execute_stack = nil\n      end\n    end\n\n    # Raise an error if validation failed.\n    #\n    # @example Raise the validation error.\n    #   Person.fail_due_to_validation!(person)\n    #\n    # @raise [ Errors::Validations ] The validation error.\n    def fail_due_to_validation!\n      raise Errors::Validations.new(self)\n    end\n\n    # Raise an error if a callback failed.\n    #\n    # @example Raise the callback error.\n    #   Person.fail_due_to_callback!(person, :create!)\n    #\n    # @param [ Symbol ] method The method being called.\n    #\n    # @raise [ Errors::Callback ] The callback error.\n    def fail_due_to_callback!(method)\n      raise Errors::Callback.new(self.class, method)\n    end\n\n    private\n\n    # Are we executing an atomically block on the current document?\n    #","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/persistable.rb#L112-L148","documentation":"Error \"Validation of %{document} failed.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/persistable.rb:130 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}