Class: Moon::Validator

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_classObject (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 messages(model)
  perform_checks model
  @messages
end