{"record":{"id":"5d24797029e2d1cb","repo":"mongodb/mongoid","slug":"invalid-option-option-provided-for-field-na","errorCode":null,"errorMessage":"Invalid option :%{option} provided for field :%{name}.","messagePattern":"Invalid option :%(.+?) provided for field :%(.+?)\\.","errorType":"exception","errorClass":"Mongoid::Errors::InvalidFieldOption","httpStatus":null,"severity":"error","filePath":"lib/mongoid/fields/validators/macro.rb","lineNumber":106,"sourceCode":"          Mongoid.logger.warn(\"Overwriting existing field #{name} in class #{klass.name}.\") if Mongoid.logger\n        end\n\n        # Validate that the field options are allowed.\n        #\n        # @api private\n        #\n        # @example Validate the field options.\n        #   Macro.validate_options(Model, :name, { localized: true })\n        #\n        # @param [ Class ] klass The model class.\n        # @param [ Symbol ] name The field name.\n        # @param [ Hash ] options The provided options.\n        #\n        # @raise [ Errors::InvalidFieldOption ] If an option is invalid.\n        def validate_options(klass, name, options)\n          options.keys.each do |option|\n            if !OPTIONS.include?(option) && !Fields.options.include?(option)\n              raise Errors::InvalidFieldOption.new(klass, name, option, OPTIONS)\n            end\n\n            Mongoid::Warnings.warn_symbol_type_deprecated if option == :type && options[option] == Symbol\n          end\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":88,"sourceCodeEnd":116,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/fields/validators/macro.rb#L88-L116","documentation":"Raised by Macro.validate_options when a field or association is declared with an option key that is not in the list of allowed options for that macro. Fires at class-load time when the field/association DSL is evaluated.","triggerScenarios":"Thrown at lib/mongoid/fields/validators/macro.rb:106 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the invalid option from the field or association declaration","Check the Mongoid documentation for the set of valid options for the macro being used","Watch for typos in option names such as :localize vs :localized"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","contentChangedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}