Sha256: dcf81f3a69e2f32d4a90bf1fbcd10968f59268ae052023e417dfe6d015f78ea6

Contents?: true

Size: 400 Bytes

Versions: 41

Compression:

Stored size: 400 Bytes

Contents

# frozen_string_literal: true

class MiniDefender::Rules::Filled < MiniDefender::Rule
  def self.signature
    'filled'
  end

  def passes?(attribute, value, validator)
    case value
    when String
      !value.strip.empty?
    when Array, Hash
      !value.empty?
    else
      !value.nil?
    end
  end

  def message(attribute, value, validator)
    'The field should not be empty.'
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
mini_defender-0.1.0 lib/mini_defender/rules/filled.rb