Class: Isomorfeus::Props::ValidateHashProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/isomorfeus/props/validate_hash_proxy.rb

Instance Method Summary collapse

Constructor Details

#initializeValidateHashProxy

Returns a new instance of ValidateHashProxy.



4
5
6
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 4

def initialize
  @validation_hash = { required: true, validate: {} }
end

Instance Method Details

#allow_nilObject



15
16
17
18
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 15

def allow_nil
  @validation_hash[:allow_nil] = true
  self
end

#ArrayObject

types



134
135
136
137
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 134

def Array
  @validation_hash[:class] = Array
  self
end

#BooleanObject



139
140
141
142
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 139

def Boolean
  @validation_hash[:type] = :boolean
  self
end

#castObject



20
21
22
23
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 20

def cast
  @validation_hash[:cast] = true
  self
end

#default(v) ⇒ Object



25
26
27
28
29
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 25

def default(v)
  @validation_hash[:required] = false
  @validation_hash[:default] = v
  self
end

#EmailObject

sub types



171
172
173
174
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 171

def Email
  @validation_hash[:type] = :email
  self
end

#ensure(v = nil, &block) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 31

def ensure(v = nil, &block)
  if block_given?
    @validation_hash[:ensure] = block
  else
    @validation_hash[:ensure] = v
  end
  self
end

#EnumerableObject



144
145
146
147
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 144

def Enumerable
  @validation_hash[:is_a] = Enumerable
  self
end

#exact_class(t_class) ⇒ Object



40
41
42
43
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 40

def exact_class(t_class)
  @validation_hash[:class] = t_class
  self
end

#FloatObject



149
150
151
152
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 149

def Float
  @validation_hash[:class] = Float
  self
end

#greater_than(v) ⇒ Object Also known as: gt



45
46
47
48
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 45

def greater_than(v)
  @validation_hash[:validate][:gt] = v
  self
end

#HashObject



154
155
156
157
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 154

def Hash
  @validation_hash[:class] = Hash
  self
end

#IntegerObject



159
160
161
162
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 159

def Integer
  @validation_hash[:class] = Integer
  self
end

#isObject Also known as: and, has, with



8
9
10
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 8

def is
  self
end

#is_a(i_class) ⇒ Object



51
52
53
54
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 51

def is_a(i_class)
  @validation_hash[:is_a] = i_class
  self
end

#keys(*keys) ⇒ Object



56
57
58
59
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 56

def keys(*keys)
  @validation_hash[:validate][:hash_keys] = keys
  self
end

#less_than(v) ⇒ Object Also known as: lt



67
68
69
70
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 67

def less_than(v)
  @validation_hash[:validate][:lt] = v
  self
end

#matches(regexp) ⇒ Object



73
74
75
76
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 73

def matches(regexp)
  @validation_hash[:validate][:matches] = regexp
  self
end

#max(l) ⇒ Object



78
79
80
81
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 78

def max(l)
  @validation_hash[:validate][:max] = l
  self
end

#max_size(l) ⇒ Object Also known as: max_length



83
84
85
86
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 83

def max_size(l)
  @validation_hash[:validate][:max_size] = l
  self
end

#min(l) ⇒ Object



89
90
91
92
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 89

def min(l)
  @validation_hash[:validate][:min] = l
  self
end

#min_size(l) ⇒ Object Also known as: min_length



94
95
96
97
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 94

def min_size(l)
  @validation_hash[:validate][:min_size] = l
  self
end

#negativeObject



100
101
102
103
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 100

def negative
  @validation_hash[:validate][:direction] = :negative
  self
end

#optionalObject



105
106
107
108
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 105

def optional
  @validation_hash[:required] = false
  self
end

#positiveObject



110
111
112
113
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 110

def positive
  @validation_hash[:validate][:direction] = :positive
  self
end

#requiredObject



115
116
117
118
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 115

def required
  @validation_hash[:required] = true
  self
end

#size(l) ⇒ Object Also known as: length



61
62
63
64
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 61

def size(l)
  @validation_hash[:validate][:size] = v
  self
end

#StringObject



164
165
166
167
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 164

def String
  @validation_hash[:class] = String
  self
end

#test(&block) ⇒ Object Also known as: condition, check



120
121
122
123
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 120

def test(&block)
  @validation_hash[:validate][:test] = block
  self
end

#to_hObject



181
182
183
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 181

def to_h
  @validation_hash
end

#UrlObject



176
177
178
179
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 176

def Url
  @validation_hash[:type] = :uri
  self
end

#validate_block(&block) ⇒ Object



127
128
129
130
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 127

def validate_block(&block)
  @validation_hash[:validate][:validate_block] = block
  self
end