Class: ParamsChecker::ParamChecker::EmailParamChecker
Instance Attribute Summary
#fields, #key, #opts
Instance Method Summary
collapse
#add_error, #initialize
Instance Method Details
#call ⇒ Object
252
253
254
255
256
|
# File 'lib/params_checker/param_checker.rb', line 252
def call
return nil if fields[key][:allow_nil] && opts[key].nil?
check_type && check_regrex && opts[key]
end
|
#check_regrex ⇒ Object
264
265
266
267
268
|
# File 'lib/params_checker/param_checker.rb', line 264
def check_regrex
valid = opts[key].match(URI::MailTo::EMAIL_REGEXP)
add_error('Invalid email.') unless valid
valid
end
|
#check_type ⇒ Object
258
259
260
261
262
|
# File 'lib/params_checker/param_checker.rb', line 258
def check_type
valid = opts[key].is_a? String
add_error("Invalid email.") unless valid
valid
end
|