File: numeric.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 (21 lines) | stat: -rw-r--r-- 405 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
module Validation
  module Rule
    # rule for numeric values
    class Numeric
      # Determines if value is numeric. It can only contain whole numbers
      def valid_value?(value)
       !!/^[0-9]+$/.match(value.to_s)
      end

      # The error key for this rule
      def error_key
        :numeric
      end

      # this rule has no params
      def params
        {}
      end
    end
  end
end