Sha256: 697ed5d72f96c11f84f5456edf24e3ef3621484ce6a44e311e2b97789afa07f7
Contents?: true
Size: 757 Bytes
Versions: 41
Compression:
Stored size: 757 Bytes
Contents
# frozen_string_literal: true class MiniDefender::Rules::NotEndingWith < MiniDefender::Rule def initialize(fragments) unless fragments.is_a?(Array) && !fragments.empty? && fragments.all? { |f| f.is_a?(String) } raise ArgumentError, 'Expected an array of strings.' end @fragments = fragments end def self.signature 'not_ending_with' end def self.make(args) new(args) end def passes?(attribute, value, validator) @fragments.any? { |f| !value.to_s.end_with?(f) } end def message(attribute, value, validator) if @fragments.length == 1 "The value should not end with #{@fragments[0]}." else "The value should not end with one of the following #{@fragments.join(', ')}." end end end
Version data entries
41 entries across 41 versions & 1 rubygems