Class: Hyrax::Transactions::Steps::Validate
- Inherits:
-
Object
- Object
- Hyrax::Transactions::Steps::Validate
- 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.
Instance Method Summary collapse
-
#call(change_set) ⇒ Dry::Monads::Result
‘Success(input)` if the change_set is valid; `Failure`, otherwise.
Instance Method Details
#call(change_set) ⇒ Dry::Monads::Result
Returns ‘Success(input)` if the change_set is valid; `Failure`, otherwise.
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 |