Sha256: 1083188a9412fa5bcaccbbec038e15eaaa5c34ea6a934e585065307523806a20
Contents?: true
Size: 467 Bytes
Versions: 13
Compression:
Stored size: 467 Bytes
Contents
module ArgsParser class Validator def validators @validators ||= [] end def add(name, message, validator) name = name.to_sym if name validators.push({:name => name, :message => message, :validator => validator}) end def validate(name, value) validators.each do |f| if !f[:name] or f[:name] == name return f[:message] unless f[:validator].call(value) end end nil end end end
Version data entries
13 entries across 13 versions & 1 rubygems