Commit ec3585b

mo <mo@mokhan.ca>
2018-09-22 21:23:42
validate timezone and locale.
1 parent 3038a43
Changed files (1)
app
models
app/models/user.rb
@@ -7,6 +7,8 @@ class User < ApplicationRecord
   validates :email, presence: true, email: true, uniqueness: {
     case_sensitive: false
   }
+  validates :timezone, inclusion: ActiveSupport::TimeZone::MAPPING.values
+  validates :locale, inclusion: { in: proc { I18n.available_locales.map(&:to_s) } }
 
   after_initialize do
     self.uuid = SecureRandom.uuid unless uuid