Add validation to addObject.
Added test for a type with custom id and type.