Sha256: 3377e557926d1b00336b0306cb4ffd23633f2b8dee8e0bec6d1284f334e64c8a

Contents?: true

Size: 400 Bytes

Versions: 55

Compression:

Stored size: 400 Bytes

Contents

module Volt
  class PresenceValidator
    def self.validate(model, field_name, args)
      errors = {}
      value  = model.get(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

55 entries across 55 versions & 1 rubygems

Version Path
volt-0.9.7.pre8 lib/volt/models/validators/presence_validator.rb
volt-0.9.7.pre7 lib/volt/models/validators/presence_validator.rb
volt-0.9.7.pre6 lib/volt/models/validators/presence_validator.rb
volt-0.9.7.pre5 lib/volt/models/validators/presence_validator.rb
volt-0.9.7.pre3 lib/volt/models/validators/presence_validator.rb
volt-0.9.7.pre2 lib/volt/models/validators/presence_validator.rb
volt-0.9.6 lib/volt/models/validators/presence_validator.rb
volt-0.9.6.pre3 lib/volt/models/validators/presence_validator.rb
volt-0.9.6.pre2 lib/volt/models/validators/presence_validator.rb
volt-0.9.6.pre1 lib/volt/models/validators/presence_validator.rb
volt-0.9.5 lib/volt/models/validators/presence_validator.rb
volt-0.9.5.pre12 lib/volt/models/validators/presence_validator.rb
volt-0.9.5.pre11 lib/volt/models/validators/presence_validator.rb
volt-0.9.5.pre9 lib/volt/models/validators/presence_validator.rb
volt-0.9.5.pre8 lib/volt/models/validators/presence_validator.rb
volt-0.9.5.pre7 lib/volt/models/validators/presence_validator.rb
volt-0.9.5.pre6 lib/volt/models/validators/presence_validator.rb
volt-0.9.5.pre5 lib/volt/models/validators/presence_validator.rb
volt-0.9.5.pre4 lib/volt/models/validators/presence_validator.rb
volt-0.9.5.pre3 lib/volt/models/validators/presence_validator.rb