Class: Isomorfeus::Props::ValidateHashProxy
- Defined in:
- lib/isomorfeus/props/validate_hash_proxy.rb
Instance Method Summary collapse
- #allow_nil ⇒ Object
-
#Array ⇒ Object
types.
- #Boolean ⇒ Object
- #cast ⇒ Object
- #default(v) ⇒ Object
-
#Email ⇒ Object
sub types.
- #ensure(v = nil, &block) ⇒ Object
- #Enumerable ⇒ Object
- #exact_class(t_class) ⇒ Object
- #Float ⇒ Object
- #greater_than(v) ⇒ Object (also: #gt)
- #Hash ⇒ Object
-
#initialize ⇒ ValidateHashProxy
constructor
A new instance of ValidateHashProxy.
- #Integer ⇒ Object
- #is ⇒ Object (also: #and, #has, #with)
- #is_a(i_class) ⇒ Object
- #keys(*keys) ⇒ Object
- #less_than(v) ⇒ Object (also: #lt)
- #matches(regexp) ⇒ Object
- #max(l) ⇒ Object
- #max_size(l) ⇒ Object (also: #max_length)
- #min(l) ⇒ Object
- #min_size(l) ⇒ Object (also: #min_length)
- #negative ⇒ Object
- #optional ⇒ Object
- #positive ⇒ Object
- #required ⇒ Object
- #size(l) ⇒ Object (also: #length)
- #String ⇒ Object
- #test(&block) ⇒ Object (also: #condition, #check)
- #to_h ⇒ Object
- #Url ⇒ Object
- #validate_block(&block) ⇒ Object
Constructor Details
#initialize ⇒ ValidateHashProxy
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_nil ⇒ Object
15 16 17 18 |
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 15 def allow_nil @validation_hash[:allow_nil] = true self end |
#Array ⇒ Object
types
134 135 136 137 |
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 134 def Array @validation_hash[:class] = Array self end |
#Boolean ⇒ Object
139 140 141 142 |
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 139 def Boolean @validation_hash[:type] = :boolean self end |
#cast ⇒ Object
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 |
#Email ⇒ Object
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] = block else @validation_hash[:ensure] = v end self end |
#Enumerable ⇒ Object
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 |
#Float ⇒ Object
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 |
#Hash ⇒ Object
154 155 156 157 |
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 154 def Hash @validation_hash[:class] = Hash self end |
#Integer ⇒ Object
159 160 161 162 |
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 159 def Integer @validation_hash[:class] = Integer self end |
#is ⇒ Object 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 |
#negative ⇒ Object
100 101 102 103 |
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 100 def negative @validation_hash[:validate][:direction] = :negative self end |
#optional ⇒ Object
105 106 107 108 |
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 105 def optional @validation_hash[:required] = false self end |
#positive ⇒ Object
110 111 112 113 |
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 110 def positive @validation_hash[:validate][:direction] = :positive self end |
#required ⇒ Object
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 |
#String ⇒ Object
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_h ⇒ Object
181 182 183 |
# File 'lib/isomorfeus/props/validate_hash_proxy.rb', line 181 def to_h @validation_hash end |
#Url ⇒ Object
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 |