basic validations and .valid?
-
hkstar
sorry, should have checked formatting before posting. Not that the code was particularly valuable, but still ..
Let me give it another shot:
@@@def validate_essentials check = ['name', 'email', 'timezone', 'password'] check.clone.each do |c|
check.delete_if {|x| x == c } if !self[c].blank?end if check.blank?
return trueelse
raise RuntimeError, check.firstend end@@@
-
hkstar
So it seems the code formatting just does not work at all. Cool.
-
hkstar
Here's a patch for a super-simple implementation of this. All it does is define a number of fields you want to check, eg.
validate :name, :email
And then refuse to save (returns false) if they're not there. Also gives you .valid? and an .invalid_fields method.
http://friendpaste.com/GWTHxAzw
Not sure if it's really the kind of thing you have in mind, but works for me :)
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.