lib/datamapper/aspects/bson_id.rb in dm-aspects-0.0.4 vs lib/datamapper/aspects/bson_id.rb in dm-aspects-0.0.5
- old
+ new
@@ -39,10 +39,14 @@
# id_is_valid?()
# # => true
#
# Returns true if ID is valid, false if not.
def id_is_valid?
- Moped::BSON::ObjectId.legal?(@id)
+ if Moped::BSON::ObjectId.legal?(@id)
+ true
+ else
+ [false, 'Id must be a valid BSON ObjectId']
+ end
end
end
end
end
end