Class: HashValidator::Base
- Inherits:
-
Object
- Object
- HashValidator::Base
- Defined in:
- lib/hash_validator/base.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#validations ⇒ Object
Returns the value of attribute validations.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash, validations) ⇒ Base
constructor
A new instance of Base.
- #valid? ⇒ Boolean
Constructor Details
#initialize(hash, validations) ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 10 11 |
# File 'lib/hash_validator/base.rb', line 5 def initialize(hash, validations) self.errors = {} self.hash = hash self.validations = validations validate end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
2 3 4 |
# File 'lib/hash_validator/base.rb', line 2 def errors @errors end |
#hash ⇒ Object
Returns the value of attribute hash.
2 3 4 |
# File 'lib/hash_validator/base.rb', line 2 def hash @hash end |
#validations ⇒ Object
Returns the value of attribute validations.
2 3 4 |
# File 'lib/hash_validator/base.rb', line 2 def validations @validations end |
Class Method Details
.strict? ⇒ Boolean
22 23 24 |
# File 'lib/hash_validator/base.rb', line 22 def self.strict? @strict end |
.validate(hash, validations, strict = false) ⇒ Object
17 18 19 20 |
# File 'lib/hash_validator/base.rb', line 17 def self.validate(hash, validations, strict = false) @strict = strict new(hash, validations) end |
Instance Method Details
#valid? ⇒ Boolean
13 14 15 |
# File 'lib/hash_validator/base.rb', line 13 def valid? errors.empty? end |