Sha256: 9d4029fbe1ca4db66ea35245f7b9496aeb39565a3fc350cab7f24b868aa62c53

Contents?: true

Size: 814 Bytes

Versions: 133

Compression:

Stored size: 814 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Validations

    # Adds localization support to validations.
    module Localizable

      # Validates each for localized fields.
      #
      # @example Validate localized fields.
      #   validator.validate_each(model, :name, "value")
      #
      # @param [ Document ] document The document.
      # @param [ Symbol, String ] attribute The attribute to validate.
      # @param [ Object ] value The attribute value.
      #
      # @since 2.4.2
      def validate_each(document, attribute, value)
        field = document.fields[attribute.to_s]
        if field.try(:localized?) && !value.blank?
          value.values.each do |_value|
            super(document, attribute, _value)
          end
        else
          super
        end
      end
    end
  end
end

Version data entries

133 entries across 87 versions & 3 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/validations/localizable.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/validations/localizable.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/validations/localizable.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/validations/localizable.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/validations/localizable.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/validations/localizable.rb
mongoid-2.8.1 lib/mongoid/validations/localizable.rb
mongoid-2.8.0 lib/mongoid/validations/localizable.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/validations/localizable.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/validations/localizable.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/validations/localizable.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/validations/localizable.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/validations/localizable.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/validations/localizable.rb
mongoid-3.1.4 lib/mongoid/validations/localizable.rb
mongoid-3.1.3 lib/mongoid/validations/localizable.rb
mongoid-2.7.1 lib/mongoid/validations/localizable.rb
mongoid-2.7.0 lib/mongoid/validations/localizable.rb
mongoid-3.1.2 lib/mongoid/validations/localizable.rb
mongoid-3.0.23 lib/mongoid/validations/localizable.rb