Sha256: ccc6b6b89c8703620b8af2120aa6c10d766458e0b24b8edc91fdc59955805e41

Contents?: true

Size: 422 Bytes

Versions: 10

Compression:

Stored size: 422 Bytes

Contents

module Volt
  class PresenceValidator
    def self.validate(model, old_model, field_name, args)
      errors = {}
      value  = model.read_attribute(field_name)
      if !value || value.blank?
        if args.is_a?(Hash) && args[:message]
          message = args[:message]
        else
          message = 'must be specified'
        end

        errors[field_name] = [message]
      end

      errors
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
volt-0.8.27.beta3 lib/volt/models/validators/presence_validator.rb
volt-0.8.27.beta2 lib/volt/models/validators/presence_validator.rb
volt-0.8.27.beta1 lib/volt/models/validators/presence_validator.rb
volt-0.8.26.beta1 lib/volt/models/validators/presence_validator.rb
volt-0.8.26 lib/volt/models/validators/presence_validator.rb
volt-0.8.24 lib/volt/models/validators/presence_validator.rb
volt-0.8.23 lib/volt/models/validators/presence_validator.rb
volt-0.8.22 lib/volt/models/validators/presence_validator.rb
volt-0.8.22.beta2 lib/volt/models/validators/presence_validator.rb
volt-0.8.22.beta1 lib/volt/models/validators/presence_validator.rb