#1037 new
TJ Holowaychuk

Apply default validations to other contexts (by default)

Reported by TJ Holowaychuk | September 11th, 2009 @ 10:50 AM

For example:

  validates_is_unique    :name,     :email
  validates_is_confirmed :password, :when => :register
  validates_is_confirmed :email,    :when => :register

When @user.valid?(:register) is called, the validates_is_unique no longer applies. As a new
user of DataMapper, I would expect this to apply, unless specifically told not to, perhaps
with something like below:

  validates_is_unique    :name,     :email, :only => :default
  validates_is_confirmed :password, :when => :register
  validates_is_confirmed :email,    :when => :register

OR

  validates_is_unique :name, :email, :when => :any

This would also be handy because the following 'shorthand' validations would need to be
moved down and contain :when => [:default, :register] to function as desired.

It is also now unclear if :length should be present as a property attribute for the table
construction, or JUST as a validation

 property :password,    String,   :length => 32, :format => :email_address

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Referenced by

Pages