Sha256: 65125249af79d1792a174f2ef5dfe2406039936931d5c1359a2ff30115b1e6c9

Contents?: true

Size: 392 Bytes

Versions: 3

Compression:

Stored size: 392 Bytes

Contents

class HashValidator::Validator::PresenceValidator < HashValidator::Validator::Base
  def initialize
    super('required')
  end

  def presence_error_message
    'is required'
  end

  def validate(key, value, _validations, errors)
    if value.nil?
      errors[key] = presence_error_message
    end
  end
end

HashValidator.append_validator(HashValidator::Validator::PresenceValidator.new)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hash_validator-1.1.0 lib/hash_validator/validators/presence_validator.rb
hash_validator-1.0.0 lib/hash_validator/validators/presence_validator.rb
hash_validator-0.8.0 lib/hash_validator/validators/presence_validator.rb