class DearInventory::Validator

Constants

DEFAULT_OPTIONS

Public Class Methods

call(field_name, value, options: DEFAULT_OPTIONS) click to toggle source
# 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
new(field_name, value, options: DEFAULT_OPTIONS) click to toggle source
# 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

Protected Instance Methods

raise_error(message) click to toggle source
# File lib/dear_inventory/validator.rb, line 57
def raise_error(message)
  raise ValidationError, "#{@field_name} is invalid, #{message}"
end

Private Instance Methods

call() click to toggle source
# File lib/dear_inventory/validator.rb, line 52
def call; end