Class: DearInventory::Validator

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/dear_inventory/validator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field_name, value, options: DEFAULT_OPTIONS) ⇒ Validator

Returns a new instance of Validator.



39
40
41
42
43
44
45
46
47
# File 'lib/dear_inventory/validator.rb', line 39

def initialize(field_name, value, options: DEFAULT_OPTIONS)
  @field_name = T.let(field_name, Symbol)
  @value =
    T.let(value, T.nilable(T.any(Date, Numeric, String, T::Boolean, Time)))

  @limit = T.let(options[:limit], T.nilable(Integer))
  @max_length = T.let(options[:limit], T.nilable(Integer))
  @values = T.let(options[:values], T.nilable(T::Array[String]))
end

Class Method Details

.call(field_name, value, options: DEFAULT_OPTIONS) ⇒ Object



28
29
30
# File 'lib/dear_inventory/validator.rb', line 28

def self.call(field_name, value, options: DEFAULT_OPTIONS)
  new(field_name, value, options: options).call
end