Sha256: a9cfae9f0859b6c8a0adfeae1b46cc8bb3c0574a2592f7be38696eb6f86412f9
Contents?: true
Size: 595 Bytes
Versions: 37
Compression:
Stored size: 595 Bytes
Contents
# frozen_string_literal: true class MiniDefender::Rules::Regex < MiniDefender::Rule def initialize(pattern) raise ArgumentError, 'Expected a Regexp instance.' unless pattern.is_a?(Regexp) @pattern = pattern end def self.signature 'regex' end def self.make(args) raise ArgumentError, 'Expected a pattern as input.' unless args.length > 0 new(Regexp.compile(args.join(','))) end def passes?(attribute, value, validator) value.to_s.match?(@pattern) end def message(attribute, value, validator) "The value must match #{@pattern.to_s}." end end
Version data entries
37 entries across 37 versions & 1 rubygems