Sha256: fd309862e00530d629ca9215afc88b0ae729aa5e8678fef6512efe5b3edb40e2
Contents?: true
Size: 732 Bytes
Versions: 21
Compression:
Stored size: 732 Bytes
Contents
# typed: true # frozen_string_literal: true module DearInventory module Validators class String < DearInventory::Validator extend T::Sig sig { override.void } def call value = instance_variable_get(:@value) return if value.nil? check_type(value) check_length(value) end private def check_type(value) return if value.is_a?(::String) raise_error("expected a String but received #{value.inspect}") end def check_length(value) length = instance_variable_get(:@length) return if length.nil? return if value.length <= length raise_error("maximum length is #{length}") end end end end
Version data entries
21 entries across 21 versions & 1 rubygems