Skip to content

Macro::Contract::Schema

Vladislav Trotsenko edited this page Sep 26, 2019 · 1 revision

Synopsis

Provides to use Dry::Validation.Schema as operation contract.

Examples of usage

Operation

With default namespace

class SomeOperation < ApplicationOperation
  step Macro::Contract::Schema(SomeContract)
  step Contract::Validate()
end

With custom namespace

class SomeOperation < ApplicationOperation
  step Macro::Contract::Schema(SomeContract, name: :some_namespace)
  step Contract::Validate(name: :some_namespace)
end

Contract

SomeContract = Dry::Validation.Schema { required(:some_attribute).filled(:str?) }
Clone this wiki locally