Class: Infold::Validation

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/infold/property/validation.rb

Defined Under Namespace

Classes: ValidateCondition

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field) ⇒ Validation

Returns a new instance of Validation.



10
11
12
13
# File 'lib/infold/property/validation.rb', line 10

def initialize(field)
  @field = field
  self.conditions = []
end

Instance Attribute Details

#conditionsObject

Returns the value of attribute conditions.



8
9
10
# File 'lib/infold/property/validation.rb', line 8

def conditions
  @conditions
end

#fieldObject (readonly)

Returns the value of attribute field.



7
8
9
# File 'lib/infold/property/validation.rb', line 7

def field
  @field
end

Instance Method Details

#add_conditions(condition, options) ⇒ Object



15
16
17
# File 'lib/infold/property/validation.rb', line 15

def add_conditions(condition, options)
  self.conditions << ValidateCondition.new(condition, options)
end

#has_presence?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/infold/property/validation.rb', line 19

def has_presence?
  conditions.find { |c| c.condition == :presence }
end