At the very least, goldfish need enough swimming room to avoid muscle atrophy. They should have enough space to swim a few body lengths in a spurt. The slim bodied fish are faster so require more horizontal space than the deeper-bodied fancy golds. They also need enough room to provide some mental stimulation. Research I’ve read suggests that they are smarter than typically thought: they have memory that can last up to 6 months, they can be taught to do tricks, they can even distinguish between different types of music. A small space provides little in the way of mental stimulation and can lead to boredom. A larger space to explore, hide and provide things with which to interact will make for a healthier fish. It is true that goldfish release a growth-inhibiting hormone that can keep them from out-growing their environment. This doesn’t seem to have any ill effect on their health; in fact, some of the longest-lived specimens stayed on the small side in relatively small tanks. This makes it difficult to definitively say whether or not your 10 gallon tank is qualitatively good enough for your fish. Although cramped, they seem to have swimming space, and they have a couple things (including each other) with which to interact. But if you choose to care for an animal, do you really only want to do the bare minimum for its survival? In my opinion, it’s pushing the boundaries of good husbandry and I wouldn’t feel good about it.
One thing I can say with certainty is that you must ensure that there’s adequate filtration. Goldfish are big waste producers so this is no easy task in a tank with such small volume. Even if you have enough surface area in the filter and tank to accommodate sufficient quantities of beneficial bacteria needed to process the ammonia/nitrite, you must monitor the build-up of nitrates which can cause health problems. You should perform water changes to dilute nitrate levels- the frequency would have to be dictated by how fast they accumulate. The problem with this is that they also dilute the hormones secreted to keep the fish from growing. So the more frequent your water changes, the less effective the growth-inhibiting hormones. Your fish will continue to grow- leaving little doubt about their being too big for the tank.