Validation question

2 views
Skip to first unread message

MarkMT

unread,
May 14, 2009, 3:39:58 PM5/14/09
to DataMapper
Is there a simple way to validate that an attribute is unique only if
it's not nil? i.e. it's fine for the attribute to be nil in multiple
records, but any non-nil value must only occur once.

Mark.

MarkMT

unread,
May 14, 2009, 4:56:58 PM5/14/09
to DataMapper
OK, think I've figured this out. Looks like
'validates_is_unique :attr_name, :allow_nil => true' does what I need.

Mark.
Reply all
Reply to author
Forward
0 new messages