Centralizing ObjectId validation