Sha256: 035423b82cbcf55897fb726badee6ba055ddba848569d1806ea14e3e9745f054

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 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.7.0 lib/bootstrap_validator_rails/validators/presence_validator.rb