File: not_empty.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-- 403 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 not empty
    class NotEmpty
      # This rule has no params
      def params
        {}
      end

      # Determines if value is empty or not. In this rule, nil is empty
      def valid_value?(value)
        ! (value.nil? || value.empty?)
      end

      # The error key for this field
      def error_key
        :not_empty
      end
    end
  end
end