Class: Form::ActiveModel::Validations::Result

Inherits:
Hash
  • Object
show all
Defined in:
lib/reform/form/active_model/validations.rb

Overview

The idea here to mimic Dry.RB’s Result API.

Defined Under Namespace

Classes: ResultErrors

Instance Method Summary collapse

Constructor Details

#initialize(success, hash) ⇒ Result

FIXME; should this be AMV::Errors?



101
102
103
104
105
# File 'lib/reform/form/active_model/validations.rb', line 101

def initialize(success, hash)
  super()
  @success = success
  hash.each { |k,v| self[k] = v }
end

Instance Method Details

#errorsObject

DISCUSS @FRAN: not sure this is 100% compatible with AMV::Errors?



120
121
122
# File 'lib/reform/form/active_model/validations.rb', line 120

def errors
  self
end

#failure?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/reform/form/active_model/validations.rb', line 111

def failure?
  ! success?
end

#messagesObject



115
116
117
# File 'lib/reform/form/active_model/validations.rb', line 115

def messages
  self
end

#success?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/reform/form/active_model/validations.rb', line 107

def success?
  @success
end