Rails: calling standard validations from a custom validator -
is there way call standard rails validators within custom validator?
i have combination of oauth/email signup/sign in , want able call validators on each method of authentication. instance, want able call validates_uniqueness_of :email
if user signs through email , call single validator, instance validates_with uservalidator
.
if there isn't way i'm going use state tracking , series of :if
validations.
i believe there's no way call other validators custom one, may possibly cause circular dependency dangerous.
you have go conditional validations, keep in mind can scope them (taken rails guides)
with_options if: :is_admin? |admin| admin.validates :password, length: { minimum: 10 } admin.validates :email, presence: true end
Comments
Post a Comment