Class: ParamsChecker::ParamChecker::EmailParamChecker

Inherits:
BaseParamChecker show all
Includes:
SimpleCommand
Defined in:
lib/params_checker/param_checker.rb

Instance Attribute Summary

Attributes inherited from BaseParamChecker

#fields, #key, #opts

Instance Method Summary collapse

Methods inherited from BaseParamChecker

#add_error, #initialize

Constructor Details

This class inherits a constructor from ParamsChecker::ParamChecker::BaseParamChecker

Instance Method Details

#callObject



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_regrexObject



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_typeObject



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