Module: DMap::Validations

Defined in:
lib/dmap/validations/core.rb,
lib/dmap/validations/format.rb,
lib/dmap/validations/length.rb,
lib/dmap/validations/method.rb,
lib/dmap/validations/within.rb,
lib/dmap/validations/absence.rb,
lib/dmap/validations/presence.rb,
lib/dmap/validations/primitive.rb,
lib/dmap/validations/uniqueness.rb,
lib/dmap/validations/confirmation.rb

Overview

Default validations if Property::Type doesn’t have it

Defined Under Namespace

Modules: Core Classes: Absence, AbsenceOf, Absent, Accept, Acceptance, Confirm, Confirmation, Format, FormatOf, LengthOf, Method, PresenceOf, Present, Primitive, PrimitiveOf, PrimitiveType, PrimitiveTypeOf, Uniqueness, UniquenessOf, WithMethod, Within

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#listObject

Returns the value of attribute list.



4
5
6
# File 'lib/dmap/validations/core.rb', line 4

def list
  @list
end

Class Method Details

.accessor(value = nil) ⇒ Object



35
36
37
# File 'lib/dmap/validations/core.rb', line 35

def accessor(value=nil)
  return true if value == "protected" or value == "private" or value == "public"
end

.add(field, validation, bucket, value) ⇒ Object

validates_*_of



48
49
50
51
52
53
# File 'lib/dmap/validations/core.rb', line 48

def add(field, validation, bucket, value)
  list[field] = {} if list[field].nil?
  list[field][validation] = {} if list[field][validation].nil?
  list[field][validation][bucket] = {} if list[field][validation][bucket].nil?
  list[field][validation].store bucket, value unless value.nil?
end

.default(value = nil) ⇒ Object



11
12
13
# File 'lib/dmap/validations/core.rb', line 11

def default(value=nil)
  true
end

.key(value = nil) ⇒ Object



23
24
25
# File 'lib/dmap/validations/core.rb', line 23

def key(value=nil)
  true
end

.lazy(value = nil) ⇒ Object



31
32
33
# File 'lib/dmap/validations/core.rb', line 31

def lazy(value=nil)
  false # Not true since lazy is loaded by default
end

.length(value = nil) ⇒ Object



15
16
17
# File 'lib/dmap/validations/core.rb', line 15

def length(value=nil)
  true if value.match /^\d+$/ or value.match /^\d+\.\.\d+$/
end

.listObject



7
8
9
# File 'lib/dmap/validations/core.rb', line 7

def list
  @list ||= Hash[]
end

.reader(value = nil) ⇒ Object



43
44
45
# File 'lib/dmap/validations/core.rb', line 43

def reader(value=nil)
  return true if value == "protected" or value == "private" or value == "public"
end

.required(value = nil) ⇒ Object



27
28
29
# File 'lib/dmap/validations/core.rb', line 27

def required(value=nil)
  true
end

.unique(value = nil) ⇒ Object



19
20
21
# File 'lib/dmap/validations/core.rb', line 19

def unique(value=nil)
  true
end

.writer(value = nil) ⇒ Object



39
40
41
# File 'lib/dmap/validations/core.rb', line 39

def writer(value=nil)
  return true if value == "protected" or value == "private" or value == "public"
end