Sha256: 850440ec5ed769784472e3be4473c945d235ae126d9ffa49ec591b166b50831c
Contents?: true
Size: 699 Bytes
Versions: 13
Compression:
Stored size: 699 Bytes
Contents
require 'hermod/validators/base' module Hermod module Validators # Checks the value matches the given regular expression class RegularExpression < Base attr_reader :pattern # Sets up the pattern the value is expected to match def initialize(pattern) @pattern = pattern end private # Public: Checks the value matches the pattern. Blank values are ignored # because those are checked by the ValuePresence validator if necessary. # # Returns a boolean def test value.blank? || value =~ pattern end def message "#{value.inspect} does not match #{pattern.inspect}" end end end end
Version data entries
13 entries across 13 versions & 1 rubygems