Sha256: d22e2a1bacd5d40b1aaa7db9272b35de68fe3f94d7fb0f52458e1f129bacd4e4
Contents?: true
Size: 610 Bytes
Versions: 16
Compression:
Stored size: 610 Bytes
Contents
module HaveAPI::Client class Validators::Numericality < Validator name :number def valid? if value.is_a?(::String) return false if /\A\d+\z/ !~ value v = value.to_i else v = value end ret = true ret = false if opts[:min] && v < opts[:min] ret = false if opts[:max] && v > opts[:max] ret = false if opts[:step] && (v - (opts[:min] || 0)) % opts[:step] != 0 ret = false if opts[:mod] && v % opts[:mod] != 0 ret = false if opts[:odd] && v % 2 == 0 ret = false if opts[:even] && v % 2 > 0 ret end end end
Version data entries
16 entries across 16 versions & 1 rubygems