Sha256: 8da419a4e523e812f24c6fdafdb24b9e0719d14b815cc24b58628de8349fa494
Contents?: true
Size: 550 Bytes
Versions: 41
Compression:
Stored size: 550 Bytes
Contents
# frozen_string_literal: true class MiniDefender::Rules::Between < MiniDefender::Rule def initialize(min, max) @min = min @max = max end def self.signature 'between' end def self.make(args) self.new(args[0].to_i, args[1].to_i) end def passes?(attribute, value, validator) case value when String, Array, Hash @min <= value.length && value.length <= @max else false end end def message(attribute, value, validator) "The value length must be between #{@min} and #{@max}." end end
Version data entries
41 entries across 41 versions & 1 rubygems