Module: CouchRest::Model::Validations

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Validations
Included in:
Base
Defined in:
lib/couchrest/model/validations.rb,
lib/couchrest/model/validations/uniqueness.rb,
lib/couchrest/model/validations/casted_model.rb

Overview

Validations may be applied to both Model::Base and Model::CastedModel

Defined Under Namespace

Modules: ClassMethods Classes: CastedModelValidator, UniquenessValidator

Instance Method Summary collapse

Instance Method Details

#valid?(context = nil) ⇒ true, false

Determine if the document is valid.

Examples:

Is the document valid?

person.valid?

Is the document valid in a context?

person.valid?(:create)

Parameters:

  • context (Symbol) (defaults to: nil)

    The optional validation context.

Returns:

  • (true, false)

    True if valid, false if not.



30
31
32
# File 'lib/couchrest/model/validations.rb', line 30

def valid?(context = nil)
  super context ? context : (new? ? :create : :update)
end