Sha256: a136c1551b0ca481c5f2f8a652b95b0b953bc6d45b4bc81a3743ac6e831d0f79
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
module BootstrapValidatorRails module Validators class Validator def initialize(record, method, validator) @record, @method, @validator = record, method, validator @js_options = {} @html_attributes = {} generate_options! end def validator_options options = @validator.try(:options) options || {} end def generate_object(options = {}) options end def unsupported? options = validator_options unsupported_options.any? { |opt| options.has_key? opt } end def html_attributes @html_attributes end def js_options {method_key => {'validators' => @js_options}} end def generate_message validator_options[:message] || i18n_message end protected def unsupported_options BootstrapValidatorRails::CONFIGURATION[:unsupported_options] end def method_key "#{@record.class.to_s.underscore.to_sym}[#{@method}]" end def i18n_message @record.errors.generate_message(@method, @validator.kind, default: '') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bootstrap_validator_rails-1.0.0 | lib/bootstrap_validator_rails/validators/validator.rb |