Explicitly cast id and validate type