improve input validation for objects and object arrays