Sha256: c4688b0cb1d94540029dd93024f36b586ec2007534bbd2193b7bc24ddb010aab
Contents?: true
Size: 854 Bytes
Versions: 1
Compression:
Stored size: 854 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 def initialize(record, method, validator) @record, @method, @validator = record, method, validator end def generate_data data = {} 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bootstrap_validator_rails-0.4.1 | lib/bootstrap_validator_rails/validators/format_validator.rb |