Sha256: c08b599737711a3336234657d15c7d91c9a41f90327b97a19812b22993796074
Contents?: true
Size: 936 Bytes
Versions: 2
Compression:
Stored size: 936 Bytes
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_options! return if unsupported? options = validator_options regex = options[:with].to_javascript regex.sub!('/^', '^') regex.sub!('$/', '$') @js_options['regexp'] = {} @html_attributes[:bv_regexp] = 'true' if options[:with] @js_options['regexp']['regexp'] = regex @html_attributes[:bv_regexp_regexp] = regex end if options[:message] @js_options['regexp']['message'] = generate_message @html_attributes[:bv_regexp_message] = generate_message end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bootstrap_validator_rails-1.1.0 | lib/bootstrap_validator_rails/validators/format_validator.rb |
bootstrap_validator_rails-1.0.0 | lib/bootstrap_validator_rails/validators/format_validator.rb |