Sha256: 1bb2ab1c86f6668b1081411e85bf92e7660717dcaf26ef204047aa1242f136fe

Contents?: true

Size: 477 Bytes

Versions: 15

Compression:

Stored size: 477 Bytes

Contents

# frozen_string_literal: true

using ObjectExtensions
using StringExtensions

module FinAppsCore
  module Utils
    # Adds validation capabilities when included into other classes
    module Validatable
      def not_blank(value, name = nil)
        raise FinAppsCore::MissingArgumentsError, name.nil? ? nil : ": #{name}" if nil_or_empty?(value)
      end

      def nil_or_empty?(value)
        !value || value.respond_to?(:empty?) && value.empty?
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
finapps_core-5.0.7 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.6 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.5 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.4 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.3 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.2 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.1 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.0 lib/finapps_core/utils/validatable.rb
finapps_core-4.0.7 lib/finapps_core/utils/validatable.rb
finapps_core-4.0.6 lib/finapps_core/utils/validatable.rb
finapps_core-4.0.5 lib/finapps_core/utils/validatable.rb
finapps_core-4.0.4 lib/finapps_core/utils/validatable.rb
finapps_core-4.0.3 lib/finapps_core/utils/validatable.rb
finapps_core-4.0.2 lib/finapps_core/utils/validatable.rb
finapps_core-4.0.0 lib/finapps_core/utils/validatable.rb