Sha256: be3956ed02990fa74f4dfd704545f5b4b215d7fd127424bdf8a86153c6833a20

Contents?: true

Size: 674 Bytes

Versions: 12

Compression:

Stored size: 674 Bytes

Contents

module Trailblazer::Operation::Procedural
  module Validate
    def validate(params, contract:self["contract.default"], path:"contract.default") # :params
      # DISCUSS: should we only have path here and then look up contract ourselves?
      result = validate_contract(contract, params) # run validation.  # FIXME: must be overridable.

      self["result.#{path}"] = result

      if valid = result.success? # FIXME: to_bool or success?
        yield result if block_given?
      else
        # self["errors.#{path}"] = result.errors # TODO: remove me
      end

      valid
    end

    def validate_contract(contract, params)
      contract.(params)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
trailblazer-2.0.7 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.6 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.5 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.4 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.3 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.2 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.1 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.0 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.0.rc1 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.0.beta3 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.0.beta2 lib/trailblazer/operation/procedural/validate.rb
trailblazer-2.0.0.beta1 lib/trailblazer/operation/procedural/validate.rb