Class: FlowEngine::Validation::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/flowengine/validation/adapter.rb

Overview

Result of validating a step answer: either valid or a list of error messages.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(valid:, errors: []) ⇒ Result

Returns a new instance of Result.

Parameters:

  • valid (Boolean) —

    whether the input passed validation

  • errors (Array<String>) (defaults to: []) —

    error messages (default: [])



13
14
15
16
17
# File 'lib/flowengine/validation/adapter.rb', line 13

def initialize(valid:, errors: [])
  @valid = valid
  @errors = errors.freeze
  freeze
end

Instance Attribute Details

#errors ⇒ Array<String> (readonly)

validation error messages (empty when valid)

Returns:

  • (Array<String>) —

    the current value of errors



8
9
10
# File 'lib/flowengine/validation/adapter.rb', line 8

def errors
  @errors
end

Instance Method Details

#valid? ⇒ Boolean

Returns true if validation passed.

Returns:

  • (Boolean) —

    true if validation passed



20
21
22
# File 'lib/flowengine/validation/adapter.rb', line 20

def valid?
  @valid
end