forked from rubygarage/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Macro::AddContractError
Vladislav Trotsenko edited this page Oct 21, 2020
·
1 revision
The point of this macros is setting custom error into ctx['contract.name']. Make sure the contract exists before using this macros.
Argument for :some_attribute is existing i18n localization.
class SomeOperation < ApplicationOperation
step Contract::Build(constant: ApplicationContract)
step Contract::Validate()
step Macro::AddContractError(some_attribute: 'errors.some_error')
endclass SomeOperation < ApplicationOperation
step Contract::Build(constant: ApplicationContract)
step Contract::Validate()
step Macro::AddContractError(name: :some_name, some_attribute: 'errors.some_error')
endclass SomeOperation < ApplicationOperation
step Contract::Build(constant: ApplicationContract)
step Contract::Validate()
step Macro::AddContractError(some_attribute_1: [:some_attribute_2, [I18n.t('errors.some_error')]])
end