Module: StrokeDB::Validations::InstanceMethods

Included in:
Document
Defined in:
lib/document/validations.rb

Overview

this module gets mixed into Document

Defined Under Namespace

Classes: Errors

Instance Method Summary collapse

Instance Method Details

#errorsObject

Returns the Errors object that holds all information about attribute error messages.



510
511
512
# File 'lib/document/validations.rb', line 510

def errors
  @errors ||= Errors.new(self)
end

#valid?Boolean

Runs validations and returns true if no errors were added otherwise false.

Returns:

  • (Boolean)


500
501
502
503
504
505
506
# File 'lib/document/validations.rb', line 500

def valid?
  errors.clear
  
  execute_callbacks :on_validation

  errors.empty?
end