Three new constraints in Sexy PG Constraints

I just added three more constraints. Finally the package feels complete.

New constraints

  • odd
  • even
  • format

The :format constraint allows you to pass your own regular expression for matching! This is intended to accompany validates_format_of in ActiveRecord.

The other two are pretty self explanatory.

It’s already pretty easy to add your own constraints to the package (just extend constraints module with more methods), but I think some macro syntax would be nicer. Something that looks good in your initializers. This will be the next step.

Don’t forget to update your gem to get these new features. The newest version as of today is 0.1.2. gem update maxim-sexy_pg_constraints --source http://gems.github.com

Leave a Reply