Sha256: 51702ef0959aecd9cae5c09bc3cbd2fb1f5ef4fcd6f758a4670660b0355e0beb
Contents?: true
Size: 925 Bytes
Versions: 15
Compression:
Stored size: 925 Bytes
Contents
# frozen_string_literal: true module LedgerSync module Util class Validator attr_reader :data, :contract def initialize(contract:, data:) @data = data @contract = contract end def errors @errors ||= call_contract.errors end def full_messages @full_messages ||= errors.messages.map { |e| "#{e.path.map(&:to_s).join(' ')} #{e.text}" } end def message @message ||= full_messages.first end def valid? call_contract.success? end def validate return success if valid? failure end private def call_contract @call_contract ||= contract.new.call(data) end def failure ValidationResult.Failure(validator: self) end def success ValidationResult.Success(validator: self) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems