Sha256: aec9aa9079c6f439ce96e6475875f4377755214100cb4d54184e432dd6d247ca
Contents?: true
Size: 601 Bytes
Versions: 4
Compression:
Stored size: 601 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 == 1 new(Regexp.compile(args[0])) 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
4 entries across 4 versions & 1 rubygems