Module: Mongoid::Fields::Validators::Macro
Overview
Validates the params passed to the field macro.
Constant Summary collapse
- FIELD_TYPE_IS_SYMBOL =
The warning message to give when a field is of type Symbol.
'The BSON symbol type is deprecated; use String instead'.freeze
- OPTIONS =
[ :as, :default, :identity, :label, :localize, :fallbacks, :association, :pre_processed, :subtype, :type, :overwrite ]
Instance Method Summary collapse
-
#validate(klass, name, options) ⇒ Object
Validate the field definition.
-
#validate_relation(klass, name, options = {}) ⇒ Object
Validate the association definition.
Instance Method Details
#validate(klass, name, options) ⇒ Object
Validate the field definition.
41 42 43 44 |
# File 'lib/mongoid/fields/validators/macro.rb', line 41 def validate(klass, name, ) validate_name(klass, name, ) (klass, name, ) end |
#validate_relation(klass, name, options = {}) ⇒ Object
Validate the association definition.
56 57 58 59 60 61 62 |
# File 'lib/mongoid/fields/validators/macro.rb', line 56 def validate_relation(klass, name, = {}) [name, "#{name}?".to_sym, "#{name}=".to_sym].each do |n| if Mongoid.destructive_fields.include?(n) raise Errors::InvalidRelation.new(klass, n) end end end |