Sha256: ef6d957fe210f0dc7f35fd14a9c96fdbc5399f0d8a222e65bcc50e201bfc2a81
Contents?: true
Size: 517 Bytes
Versions: 13
Compression:
Stored size: 517 Bytes
Contents
class HashValidator::Validator::SimpleValidator < HashValidator::Validator::Base attr_accessor :lambda def initialize(name, lambda) # lambda must accept one argument (the value) if lambda.arity != 1 raise StandardError.new("lambda should take only one argument - passed lambda takes #{lambda.arity}") end super(name) self.lambda = lambda end def validate(key, value, validations, errors) unless lambda.call(value) errors[key] = presence_error_message end end end
Version data entries
13 entries across 13 versions & 1 rubygems