Sha256: 52509b6a3cff23db083bb13505cffda5f9bbaaf7086b63d735f34428b3faac3d

Contents?: true

Size: 576 Bytes

Versions: 6

Compression:

Stored size: 576 Bytes

Contents

class HashValidator::Base
  attr_accessor :hash, :validations, :errors


  def initialize(hash, validations)
    self.errors      = {}
    self.hash        = hash
    self.validations = validations
    
    validate
  end

  def valid?
    errors.empty?
  end

  def self.validate(hash, validations, strict = false)
    @strict = strict
    new(hash, validations)
  end
  
  def self.strict?
    @strict
  end
  
  private
  def validate
    HashValidator.validator_for(hash).validate(:base, self.hash, self.validations, self.errors)
    self.errors = errors[:base]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hash_validator-0.8.0 lib/hash_validator/base.rb
hash_validator-0.7.1 lib/hash_validator/base.rb
hash_validator-0.7.0 lib/hash_validator/base.rb
hash_validator-0.6.0 lib/hash_validator/base.rb
hash_validator-0.5.0 lib/hash_validator/base.rb
hash_validator-0.4.0 lib/hash_validator/base.rb