Sha256: 81c3ccdf580518a773f4e15c5981a2078d533178e3152d841cd95b1a87ad98df

Contents?: true

Size: 536 Bytes

Versions: 3

Compression:

Stored size: 536 Bytes

Contents

class HashValidator::Validator::Base
  attr_accessor :name


  def initialize(name)
    self.name = name.to_s

    unless self.name.size > 0
      raise StandardError.new('Validator must be initialized with a valid name (length greater than zero)')
    end
  end

  def should_validate?(name)
    self.name == name.to_s
  end

  def presence_error_message
    "#{self.name} required"
  end

  def validate(key, value, validations, errors)
    raise StandardError.new('validate should not be called directly on BaseValidator')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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