Module: Mongoid::Fields::Validators::Macro

Extended by:
Macro
Included in:
Macro
Defined in:
lib/mongoid/fields/validators/macro.rb

Overview

Validates the params passed to the field macro.

Constant Summary collapse

OPTIONS =
[
  :as,
  :default,
  :identity,
  :label,
  :localize,
  :metadata,
  :pre_processed,
  :subtype,
  :type,
  :overwrite
]

Instance Method Summary collapse

Instance Method Details

#validate(klass, name, options) ⇒ Object

Validate the field definition.

Examples:

Validate the field definition.

Macro.validate(Model, :name, { localized: true })

Parameters:

  • klass (Class)

    The model class.

  • name (Symbol)

    The field name.

  • options (Hash)

    The provided options.

Since:

  • 3.0.0


33
34
35
36
# File 'lib/mongoid/fields/validators/macro.rb', line 33

def validate(klass, name, options)
  validate_name(klass, name, options)
  validate_options(klass, name, options)
end