Sha256: 3f4554cfa24b3ddf2c47923bee820208f7debca7105b64cb718ecaca2d5f569f

Contents?: true

Size: 391 Bytes

Versions: 4

Compression:

Stored size: 391 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

4 entries across 4 versions & 1 rubygems

Version Path
hash_validator-0.7.1 lib/hash_validator/validators/presence_validator.rb
hash_validator-0.7.0 lib/hash_validator/validators/presence_validator.rb
hash_validator-0.6.0 lib/hash_validator/validators/presence_validator.rb
hash_validator-0.5.0 lib/hash_validator/validators/presence_validator.rb