Class: BootstrapValidatorRails::Validators::Format
- Defined in:
- lib/bootstrap_validator_rails/validators/format_validator.rb
Instance Method Summary collapse
Methods inherited from Validator
#initialize, #unsupported?, #validator_options
Constructor Details
This class inherits a constructor from BootstrapValidatorRails::Validators::Validator
Instance Method Details
#generate_data ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bootstrap_validator_rails/validators/format_validator.rb', line 10 def generate_data data = {} return data if unsupported? = regex = [:with].to_javascript regex.sub!('/^', '^') regex.sub!('$/', '$') data[:bv_regexp] = 'true' if [:with] data[:bv_regexp_regexp] = regex end if [:message] data[:bv_regexp_message] = [:message] end data end |
#generate_object ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bootstrap_validator_rails/validators/format_validator.rb', line 33 def generate_object data = {} return data if unsupported? = regex = [:with].to_javascript regex.sub!('/^', '^') regex.sub!('$/', '$') data["regexp"] = {} if [:with] data["regexp"]["regexp"] = regex end if [:message] data["regexp"]["message"] = [:message] end {method_key => {'validators' => data}} end |