class HashValidator::Base

Attributes

errors[RW]
hash[RW]
validations[RW]

Public Class Methods

new(hash, validations) click to toggle source
# File lib/hash_validator/base.rb, line 5
def initialize(hash, validations)
  self.errors      = {}
  self.hash        = hash
  self.validations = validations

  validate
end
strict?() click to toggle source
# File lib/hash_validator/base.rb, line 22
def self.strict?
  @strict
end
validate(hash, validations, strict = false) click to toggle source
# File lib/hash_validator/base.rb, line 17
def self.validate(hash, validations, strict = false)
  @strict = strict
  new(hash, validations)
end

Public Instance Methods

valid?() click to toggle source
# File lib/hash_validator/base.rb, line 13
def valid?
  errors.empty?
end

Private Instance Methods

validate() click to toggle source
# File lib/hash_validator/base.rb, line 28
def validate
  HashValidator.validator_for(hash).validate(:base, self.hash, self.validations, self.errors)
  self.errors = errors[:base]
end