Sha256: 671e2fc313e4327362cfcb08b239b9ff954d1688ab6547313bf4c0d98dcc4de6

Contents?: true

Size: 551 Bytes

Versions: 1

Compression:

Stored size: 551 Bytes

Contents

module Common
  def self.required(args)
    lambda do |value, unuse, unuse_|
      return 'REQUIRED' if value.nil? or value.eql?('')
    end
  end

  def self.not_empty(args)
    lambda do |value, unuse, unuse_|
      return 'CANNOT_BE_EMPTY' if !value.nil? and value.eql?('')
    end
  end

  def self.not_empty_list(args)
    lambda do |list, unuse, unuse_|
      return 'CANNOT_BE_EMPTY' if list.eql?('') or list.nil?
      return 'WRONG_FORMAT'    unless list.kind_of? Array
      return 'CANNOT_BE_EMPTY' if list.size.equal?(0)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
livr-0.0.2 lib/LIVR/Rules/Common.rb