Ah [new?] will work great. I figured there was some sort of method I could call.
Could I recommend the validations_rdoc page be updated with this for other users? Thanks for the reply as always Jeremy. Jeremy Swatwood On Monday, March 7, 2016 at 5:53:55 PM UTC-9, Jeremy Evans wrote: > > On Monday, March 7, 2016 at 5:30:06 PM UTC-8, Jeremy Swartwood wrote: >> >> Is there a way to perform validate only certain operations? >> >> Like on Delete or update or create ? >> > > Sequel doesn't have delete/destroy valiations, only save validations. > >> >> I have a scenario where updating doesn't matter for the validation. >> >> Unless I missed it, I don't see that described here: >> http://sequel.jeremyevans.net/rdoc/files/doc/validations_rdoc.html >> >> > Validations are instance-level in Sequel, and new? can be used to check > whether the record is new (create) or not (update): > > def validate > super > if new? > # create validations > else > # update validations > end > end > > Thanks, > Jeremy > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
