|
|
|
@ -42,9 +42,9 @@ class Bid < ActiveRecord::Base
|
|
|
|
|
validates :author_id, presence: true
|
|
|
|
|
validates :deadline, presence: true, format: {:with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/}
|
|
|
|
|
validates :name, length: {maximum: NAME_LENGTH_LIMIT}
|
|
|
|
|
validates :budget,
|
|
|
|
|
format: {with : /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/, if: Proc.new { |p| p.reward_type == 1 }},
|
|
|
|
|
format: {with: /^(\d+)$|^(\d+).([0-9]{1})$/, if: Proc.new { |p| p.reward_type == 3 }}
|
|
|
|
|
validates :budget, format: { with: ->(p) { if p.reward_type == 1 then /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/
|
|
|
|
|
elsif p.reward_type == 3 then /^(\d+)$|^(\d+).([0-9]{1})$/ end } }
|
|
|
|
|
|
|
|
|
|
validate :validate_user
|
|
|
|
|
validate :validate_reward_type
|
|
|
|
|
after_create :act_as_activity
|
|
|
|
|