Class: LIVR::Rules::Numeric::PositiveInteger
- Inherits:
-
LIVR::Rule
- Object
- LIVR::Rule
- LIVR::Rules::Numeric::PositiveInteger
- Defined in:
- lib/livr/rules/numeric.rb
Instance Method Summary collapse
Methods inherited from LIVR::Rule
Constructor Details
This class inherits a constructor from LIVR::Rule
Instance Method Details
#call(value, user_data, field_results) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/livr/rules/numeric.rb', line 22 def call(value, user_data, field_results) return if is_no_value(value) return 'FORMAT_ERROR' if !is_primitive(value) value_int = Integer(value.to_s) rescue nil return "NOT_POSITIVE_INTEGER" if value_int.nil? return "NOT_POSITIVE_INTEGER" unless value_int.positive? field_results << value_int return end |