Class: ParamsChecker::ParamChecker::ArrParamChecker
Instance Attribute Summary
#fields, #key, #opts
Instance Method Summary
collapse
#add_error, #initialize
Instance Method Details
#call ⇒ Object
102
103
104
105
106
|
# File 'lib/params_checker/param_checker.rb', line 102
def call
return nil if fields[key][:allow_nil] && opts[key].nil?
check_type && check_allow_empty && opts[key]
end
|
#check_allow_empty ⇒ Object
114
115
116
117
118
|
# File 'lib/params_checker/param_checker.rb', line 114
def check_allow_empty
valid =!(!fields[key][:allow_empty] && opts[key].empty?)
add_error('This field cannot be empty.') unless valid
valid
end
|
#check_type ⇒ Object
108
109
110
111
112
|
# File 'lib/params_checker/param_checker.rb', line 108
def check_type
valid =opts[key].is_a? Array
add_error("This field's type must be array.") unless valid
valid
end
|