Sha256: 3a693c41f7032c634159600eb7b694a65718c5cfeca33ab240f447137ff891aa
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
module BootstrapValidatorRails module Validators class Numericality < Validator def generate_data data = {} return data if unsupported? options = validator_options data[:bv_numeric] = 'true' data[:bv_numeric_separator] = '.' data.merge(generate_options) end def generate_message @record.errors.generate_message(@method, :presence, {default: 'should be a number'}) end def generate_options options = @validator.options data = {} if options[:only_integer].present? data[:bv_integer] = 'true' end if options[:greater_than].present? data[:bv_greaterthan] = 'true' data[:bv_greaterthan_inclusive] = 'false' data[:bv_greaterthan_value] = options[:greater_than] end if options[:greater_than_or_equal_to].present? data[:bv_greaterthan] = 'true' data[:bv_greaterthan_inclusive] = 'true' data[:bv_greaterthan_value] = options[:greater_than_or_equal_to] end if options[:less_than].present? data[:bv_lessthan] = 'true' data[:bv_lessthan_inclusive] = 'false' data[:bv_lessthan_value] = options[:less_than] end if options[:less_than_or_equal_to].present? data[:bv_lessthan] = 'true' data[:bv_lessthan_inclusive] = 'true' data[:bv_lessthan_value] = options[:less_than_or_equal_to] end data end end end end
Version data entries
2 entries across 2 versions & 1 rubygems