Sha256: 445fd1f7d72e88231ecfeb52a71e8edada4ea97d779a7cf6f966421a740d41c3

Contents?: true

Size: 361 Bytes

Versions: 32

Compression:

Stored size: 361 Bytes

Contents

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

    return errors
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
volt-0.8.14 lib/volt/models/validators/presence_validator.rb
volt-0.8.13 lib/volt/models/validators/presence_validator.rb
volt-0.8.11 lib/volt/models/validators/presence_validator.rb
volt-0.8.10 lib/volt/models/validators/presence_validator.rb
volt-0.8.9 lib/volt/models/validators/presence_validator.rb
volt-0.8.8 lib/volt/models/validators/presence_validator.rb
volt-0.8.7 lib/volt/models/validators/presence_validator.rb
volt-0.8.6 lib/volt/models/validators/presence_validator.rb
volt-0.8.5 lib/volt/models/validators/presence_validator.rb
volt-0.8.4 lib/volt/models/validators/presence_validator.rb
volt-0.8.3 lib/volt/models/validators/presence_validator.rb
volt-0.8.2 lib/volt/models/validators/presence_validator.rb
volt-0.8.1 lib/volt/models/validators/presence_validator.rb
volt-0.8.0 lib/volt/models/validators/presence_validator.rb
volt-0.7.23 lib/volt/models/validators/presence_validator.rb
volt-0.7.22 lib/volt/models/validators/presence_validator.rb
volt-0.7.21 lib/volt/models/validators/presence_validator.rb
volt-0.7.20 lib/volt/models/validators/presence_validator.rb
volt-0.7.19 lib/volt/models/validators/presence_validator.rb
volt-0.7.18 lib/volt/models/validators/presence_validator.rb