Sha256: 440ffdf38f87a73ae9cebb400d9d2af03a85d8219db069cb24e3cda4eb26caf4
Contents?: true
Size: 607 Bytes
Versions: 37
Compression:
Stored size: 607 Bytes
Contents
# frozen_string_literal: true class MiniDefender::Rules::NotRegex < MiniDefender::Rule def initialize(pattern) raise ArgumentError, 'Expected a Regexp instance.' unless pattern.is_a?(Regexp) @pattern = pattern end def self.signature 'not_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 not match #{@pattern.to_s}." end end
Version data entries
37 entries across 37 versions & 1 rubygems