
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
-
TJ Holowaychuk September 11th, 2009 @ 10:56 AM
or
validates :register, :as => :default
Just throwing some ideas out there :)
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.
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
Tags
Referenced by
-
1096 Issues with Contextual validations when some validations don't specify a context I think this is a duplicate of #1037