Sha256: a4a1014b6c93d7d0322be0a3575f7c19d8ea2aef5326fcb533114a659c2e8337

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true

module BCDD::Contract
  module Core::Checking
    attr_reader :value, :errors

    def initialize(_checker, _value)
      raise Error, 'not implemented'
    end

    def valid?
      errors.empty?
    end

    def invalid?
      !valid?
    end

    alias errors? invalid?

    def errors_message
      raise Error, 'not implemented'
    end

    def raise_validation_errors!
      raise Error, errors_message if invalid?
    end

    def value_or_raise_validation_errors!
      raise_validation_errors! || value
    end

    alias !@ value_or_raise_validation_errors!
    alias +@ value_or_raise_validation_errors!
    alias value! value_or_raise_validation_errors!
    alias assert! value_or_raise_validation_errors!
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bcdd-contract-0.1.0 lib/bcdd/contract/core/checking.rb