Class: RepoTender::Config::Contract

Inherits:
Dry::Validation::Contract
  • Object
show all
Defined in:
lib/repo_tender/config/contract.rb

Overview

Validates the raw YAML hash before it is built into a Config struct. Returns a Dry::Monads::Result (via the :monads extension):

Success(validated_hash)  — keys are coerced + bad keys dropped
Failure(errors_to_h)     — field-level messages keyed by path

Per gate G2, each rejection case (missing required field, bad refresh_interval, non-integer concurrency, malformed repo entry, malformed org entry) must produce a Failure with a field-level message — verified by Config::ContractTest.

Instance Method Summary collapse

Instance Method Details

#call(input) ⇒ Object

Override call to return a Dry::Monads::Result. Dry-validation’s monads extension gives us Result#to_monad; we map to our own namespace so callers see a single Result type at every boundary.



43
44
45
46
47
48
49
50
# File 'lib/repo_tender/config/contract.rb', line 43

def call(input)
  result = super
  if result.success?
    Success(result.to_h)
  else
    Failure(result.errors.to_h)
  end
end