Class: Redmine::FieldFormat::Unbounded

Inherits:
Base
  • Object
show all
Defined in:
lib/redmine/field_format.rb

Direct Known Subclasses

DateFormat, Numeric, StringFormat, TextFormat

Instance Method Summary collapse

Methods inherited from Base

#after_save_custom_value, #before_custom_field_save, #bulk_edit_tag, #cast_custom_value, #cast_single_value, #cast_value, #edit_tag, field_attributes, #formatted_custom_value, #formatted_value, #group_statement, #join_for_order_statement, #label, #name, #order_statement, #possible_custom_value_options, #possible_values_options, #query_filter_options, #sanitize_html, #set_custom_field_value, #target_class, #validate_custom_field, #validate_custom_value, #value_from_keyword

Methods included from Helpers::URL

#uri_with_link_safe_scheme?, #uri_with_safe_scheme?

Methods included from I18n

#abbr_day_name, #current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, included, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #normalize_float, #set_language_if_valid, #valid_languages

Instance Method Details

#validate_single_value(custom_field, value, customized = nil) ⇒ Object



379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/redmine/field_format.rb', line 379

def validate_single_value(custom_field, value, customized=nil)
  errs = super
  value = value.to_s
  unless custom_field.regexp.blank? or Regexp.new(custom_field.regexp).match?(value)
    errs << ::I18n.t('activerecord.errors.messages.invalid')
  end
  if custom_field.min_length && value.length < custom_field.min_length
    errs << ::I18n.t('activerecord.errors.messages.too_short', :count => custom_field.min_length)
  end
  if custom_field.max_length && custom_field.max_length > 0 && value.length > custom_field.max_length
    errs << ::I18n.t('activerecord.errors.messages.too_long', :count => custom_field.max_length)
  end
  errs
end