Class: Hyrax::Transactions::Steps::Validate

Inherits:
Object
  • Object
show all
Defined in:
lib/hyrax/transactions/steps/validate.rb

Overview

Validates a ChangeSet, returning ‘Success(change_set)` if valid, and a `Failure` including the errors otherwise.

Callers provide the particular ‘ChangeSet` to validate, and its validity status is delegated by its own configuration/implementation.

It is good practice to run this validation as a precursor to any step that will sync a ChangeSet or save its resource. A ‘Failure` return value in the context of a transaction will prevent the sync/save step from running.

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

#call(change_set) ⇒ Dry::Monads::Result

Returns ‘Success(input)` if the change_set is valid; `Failure`, otherwise.

Parameters:

Returns:

  • (Dry::Monads::Result)

    ‘Success(input)` if the change_set is valid; `Failure`, otherwise.

Since:

  • 3.0.0



28
29
30
31
32
# File 'lib/hyrax/transactions/steps/validate.rb', line 28

def call(change_set)
  return Success(change_set) if change_set.valid?

  Failure([:failed_validation, change_set.errors])
end