Class: Cuprum::Rails::Commands::ValidateOne
- Inherits:
-
Cuprum::Rails::Command
- Object
- Collections::Command
- Cuprum::Rails::Command
- Cuprum::Rails::Commands::ValidateOne
- Defined in:
- lib/cuprum/rails/commands/validate_one.rb
Overview
Command for validating an ActiveRecord record.
Instance Attribute Summary
Attributes inherited from Cuprum::Rails::Command
#collection_name, #member_name, #options, #record_class
Instance Method Summary collapse
-
#call(entity: , contract: nil) ⇒ Cuprum::Result<ActiveRecord::Base>
Validates the record against the given or default contract.
Methods inherited from Cuprum::Rails::Command
#initialize, #primary_key_name, #primary_key_type, subclass
Constructor Details
This class inherits a constructor from Cuprum::Rails::Command
Instance Method Details
#call(entity: , contract: nil) ⇒ Cuprum::Result<ActiveRecord::Base>
Validates the record against the given or default contract.
If the record matches the contract, #call will return a passing result with the record as the result value. If the record does not match the contract, #call will return a failing result with a FailedValidation error and the validation errors.
26 27 28 29 30 31 |
# File 'lib/cuprum/rails/commands/validate_one.rb', line 26 validate_parameters :call do keyword :contract, Stannum::Constraints::Base, optional: true keyword :entity, Object end |