File: regular_expression.rb

package info (click to toggle)
ruby-valid 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 128 kB
  • sloc: ruby: 309; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 340 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Validation
  module Rule
    class RegularExpression

      def initialize(params)
        @params = params
      end

      def error_key
        :regular_expression
      end

      def valid_value?(value)
        value.nil? || !!@params[:regex].match(value)
      end

      def params
        @params
      end
    end
  end
end