Sha256: 0152b5a2e4ef1128f6b18def6265bd4f4265746c144759f5b5580f6bd8f07348

Contents?: true

Size: 476 Bytes

Versions: 10

Compression:

Stored size: 476 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)
        fail 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

10 entries across 10 versions & 1 rubygems

Version Path
finapps_core-6.0.1 lib/finapps_core/utils/validatable.rb
finapps_core-6.0.0 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.16 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.15 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.14 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.13 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.11 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.10 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.9 lib/finapps_core/utils/validatable.rb
finapps_core-5.0.8 lib/finapps_core/utils/validatable.rb