Sha256: 13fe4f1b1e47087010aef2c97c3666a91e2e3cd05e4b9abcb68f9f576b81cfa7
Contents?: true
Size: 704 Bytes
Versions: 41
Compression:
Stored size: 704 Bytes
Contents
# frozen_string_literal: true class MiniDefender::Rules::Different < MiniDefender::Rule def initialize(other_field) raise ArgumentError, 'Other field must be a string' unless other_field.is_a?(String) @found = false @other_field = other_field end def self.signature 'different' end def self.make(args) self.new(args[0]) end def passes?(attribute, value, validator) @found, @other = validator.data.key?(@other_field), validator.data[@other_field] @found && value == @other end def message(attribute, value, validator) if @found "The field does not match \"#{@other}\"." else "The field must match #{@other_field}." end end end
Version data entries
41 entries across 41 versions & 1 rubygems