Class: ValidateParams::Validatable::ParamValidator
- Inherits:
-
Object
- Object
- ValidateParams::Validatable::ParamValidator
- Defined in:
- lib/validate_params/param_validator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(type:, field:, value:, errors:, options: {}) ⇒ ParamValidator
constructor
A new instance of ParamValidator.
Constructor Details
#initialize(type:, field:, value:, errors:, options: {}) ⇒ ParamValidator
Returns a new instance of ParamValidator.
12 13 14 15 16 17 18 |
# File 'lib/validate_params/param_validator.rb', line 12 def initialize(type:, field:, value:, errors:, options: {}) @type = type @field = field @value = value @errors = errors = end |
Class Method Details
.call(**args) ⇒ Object
8 9 10 |
# File 'lib/validate_params/param_validator.rb', line 8 def self.call(**args) new(**args).call end |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/validate_params/param_validator.rb', line 20 def call return if @value.blank? && ![:required] if @value.blank? && [:required] @errors << { message: } return end send(@type.to_s.underscore) end |