Module: NoBrainer::Document::Validation::Core

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Validations, ActiveModel::Validations::Callbacks
Defined in:
lib/no_brainer/document/validation/core.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

SHORTHANDS =
{ :format => :format, :length => :length, :required => :presence,
:uniq => :uniqueness, :unique => :uniqueness, :in => :inclusion }

Instance Method Summary collapse

Instance Method Details

#save?(options = {}) ⇒ Boolean

Returns:



15
16
17
18
19
20
21
22
23
# File 'lib/no_brainer/document/validation/core.rb', line 15

def save?(options={})
  options = { :validate => true }.merge(options)

  if options[:validate]
    valid? ? super : false
  else
    super
  end
end

#valid?(context = nil, options = {}) ⇒ Boolean

Returns:



11
12
13
# File 'lib/no_brainer/document/validation/core.rb', line 11

def valid?(context=nil, options={})
  super(context || (new_record? ? :create : :update))
end