There is no effective validator for PDFs. This has been a difficulty since the start.
My personal recommendation is to write a PDF consumer as a separate project following the rules of PDF. This will teach you a lot about what you need to write a PDF creator. For example, imagine a consumer which needs to efficiently read a PDF of several gigabytes. The consumer must be able to read the xref table(s), get a byte address, and go directly to read the object. If the xref table is very long, the consumer needs to be able to use
xref segment address + object number*20 - first object number in segment
to find just the entry it wants. This shows the importance of the xref, which is seen as a baffling and unnecessary detail by many people starting to write short PDF files.