Sha256: e23d1fb4ff25d6533050d7561f479acd85ec8918a6b407c059e29c347a3c34be

Contents?: true

Size: 311 Bytes

Versions: 8

Compression:

Stored size: 311 Bytes

Contents

module Compel
  module Validation

    class Format < Condition

      def validate_value
        if value_type == Coercion::String && !valid?
          "must match format #{option_value.source}"
        end
      end

      def valid?
        !value.nil? && value =~ option_value
      end

    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
compel-0.5.1 lib/compel/validation/conditions/format.rb
compel-0.5.0 lib/compel/validation/conditions/format.rb
compel-0.4.3 lib/compel/validation/conditions/format.rb
compel-0.4.2 lib/compel/validation/conditions/format.rb
compel-0.4.0 lib/compel/validation/conditions/format.rb
compel-0.3.7 lib/compel/validation/conditions/format.rb
compel-0.3.6 lib/compel/validation/conditions/format.rb
compel-0.3.4 lib/compel/validation/conditions/format.rb