Sha256: 8fd56ea25a987f15910a0f026ccfc3c7709deab7cde4b6a420d2d5b52864c66a
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
class Regexp def to_javascript Regexp.new(inspect.sub('\\A','^').sub('\\Z','$').sub('\\z','$').sub(/^\//,'').sub(/\/[a-z]*$/,'').gsub(/\(\?#.+\)/, '').gsub(/\(\?-\w+:/,'('), self.options).inspect end end module BootstrapValidatorRails module Validators class Format < Validator def generate_data data = {} return data if unsupported? options = validator_options regex = options[:with].to_javascript regex.sub!('/^', '^') regex.sub!('$/', '$') data[:bv_regexp] = 'true' if options[:with] data[:bv_regexp_regexp] = regex end if options[:message] data[:bv_regexp_message] = options[:message] end data end def generate_object data = {} return data if unsupported? options = validator_options regex = options[:with].to_javascript regex.sub!('/^', '^') regex.sub!('$/', '$') data["regexp"] = {} if options[:with] data["regexp"]["regexp"] = regex end if options[:message] data["regexp"]["message"] = options[:message] end {method_key => {'validators' => data}} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bootstrap_validator_rails-0.7.0 | lib/bootstrap_validator_rails/validators/format_validator.rb |