validates_uniqueness_of has a ‘scope’ option that will do exactly what you’re describing:
class Customer < ActiveRecord::Base
belongs_to :user
validates_uniqueness_of :customernumber, :scope => :user_id
end
Depending on what you’re intending to use the customer number for, you may also want to take a look at something like acts_as_list.
–Matt Jones