Sha256: b7f68af7f70237932064beb0e395f6c564eadbdc4482fefa54303f2e7b108694

Contents?: true

Size: 298 Bytes

Versions: 3

Compression:

Stored size: 298 Bytes

Contents

module SimpleValidate
  class ValidatesFormatOf < ValidatesBase

    def initialize(attribute, options)
      @regex = options[:with]
      super(attribute, options[:message] || "is incorrect format")
    end

    def valid?(instance)
      !!(instance.send(attribute) =~ @regex)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple_validate-1.1.1 lib/simple_validate/validates_format_of.rb
simple_validate-1.1.0 lib/simple_validate/validates_format_of.rb
simple_validate-1.0.0 lib/simple_validate/validates_format_of.rb