Class: Moon::Validator
- Inherits:
-
Object
- Object
- Moon::Validator
- Defined in:
- lib/moon/validator.rb
Overview
Generic validator class. Can be used to validate model attributes.
Defined Under Namespace
Classes: Format, Length, Presence
Instance Attribute Summary collapse
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
Instance Method Summary collapse
-
#initialize(context, checks) ⇒ Validator
constructor
A new instance of Validator.
- #messages(model) ⇒ Object
Constructor Details
#initialize(context, checks) ⇒ Validator
Returns a new instance of Validator.
11 12 13 |
# File 'lib/moon/validator.rb', line 11 def initialize(context, checks) @context, @checks = context, checks end |
Instance Attribute Details
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
9 10 11 |
# File 'lib/moon/validator.rb', line 9 def model_class @model_class end |
Instance Method Details
#messages(model) ⇒ Object
15 16 17 18 |
# File 'lib/moon/validator.rb', line 15 def (model) perform_checks model @messages end |