adds validation for min-max length

pull/1669/head
Jonas Heinrich 10 years ago
parent 6dcdb46a67
commit f8ae39b9bb
  1. 6
      app/models/custom_field.rb
  2. 1
      config/locales/de.yml
  3. 1
      config/locales/en.yml

@ -74,6 +74,12 @@ class CustomField < ActiveRecord::Base
validate :validate_default_value_in_translations
validate :validate_name
validates :min_length, numericality: { only_integer: true, :greater_than_or_equal => 0 }
validates :max_length, numericality: { only_integer: true, :greater_than_or_equal => 0 }
validates :min_length, numericality: { :less_than_or_equal_to => :max_length , :message => :greater_than_or_equal_to_max_length}, :unless => Proc.new { |cf| cf.max_length.blank?}
def initialize(attributes = nil, options = {})
super

@ -196,6 +196,7 @@ de:
exclusion: "ist nicht verfügbar"
greater_than: "muss größer als %{count} sein"
greater_than_or_equal_to: "muss größer oder gleich %{count} sein"
greater_than_or_equal_to_max_length: "muss größer oder gleich der maximalen Länge sein"
greater_than_start_date: "muss größer als Anfangsdatum sein"
inclusion: "ist kein gültiger Wert"
invalid: "ist nicht gültig"

@ -196,6 +196,7 @@ en:
exclusion: "is reserved"
greater_than: "must be greater than %{count}"
greater_than_or_equal_to: "must be greater than or equal to %{count}"
greater_than_or_equal_to_max_length: "must be greater than or equal to maximum length"
greater_than_start_date: "must be greater than start date"
inclusion: "is not included in the list"
invalid: "is invalid"

Loading…
Cancel
Save