Sha256: a700fe6e84e1e95dd53ba32e2a642befac544fd4a4dd197cbb7e0bec116faa2f

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

module BootstrapValidatorRails
  module Validators
    class Presence < Validator
      def generate_data
        data = {}
        return data if unsupported?

        data[:bv_notempty] = 'true'
        data[:bv_notempty_message] = generate_message
        data
      end

      def generate_message
        @record.errors.generate_message(@method, :blank, default: "can't be blank")
      end

      def generate_object(options = {})
        data = {}
        data["notEmpty"] = {}
        data["notEmpty"]["message"] = generate_message
        {method_key => {validators: data}}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bootstrap_validator_rails-0.6.0 lib/bootstrap_validator_rails/validators/presence_validator.rb